如何在 Xamarin 中使用 Dropbox for Android 解决 "Error CS0120: An object reference is required for the non-static field, method, or property"?
How to resolve "Error CS0120: An object reference is required for the non-static field, method, or property" using Dropbox for Android in Xamarin?
我完全按照这个例子:
protected async override void OnStart ()
{
base.OnStart ();
AppKeyPair appKeys = new AppKeyPair(AppKey, AppSecret);
AndroidAuthSession session = new AndroidAuthSession(appKeys);
dropboxApi = new DropboxAPI (session);
(DropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication (this);
}
但我收到错误:
Error CS0120: An object reference is required for the non-static field, method, or property 'Dropbox.CoreApi.Android.DropboxApi.Session.get' (CS0120)
在下一行:
(DropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication (this);
这部分:
(DropboxApi.Session as AndroidAuthSession)
应该是:
(dropboxApi.Session as AndroidAuthSession)
注意大写字母 D 引用 class 而不是实例。
我完全按照这个例子:
protected async override void OnStart ()
{
base.OnStart ();
AppKeyPair appKeys = new AppKeyPair(AppKey, AppSecret);
AndroidAuthSession session = new AndroidAuthSession(appKeys);
dropboxApi = new DropboxAPI (session);
(DropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication (this);
}
但我收到错误:
Error CS0120: An object reference is required for the non-static field, method, or property 'Dropbox.CoreApi.Android.DropboxApi.Session.get' (CS0120)
在下一行:
(DropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication (this);
这部分:
(DropboxApi.Session as AndroidAuthSession)
应该是:
(dropboxApi.Session as AndroidAuthSession)
注意大写字母 D 引用 class 而不是实例。