我正在Xamarin Studio 5.5.3上使用Xamarin Android,我试图创建一个使用示例的全局会话状态此链接:Xamarin Android全局会话变量 - 错误没有找到构造函数(System.IntPtr,Android.Runtime.JniHandleOwnership)
Login Session - Activities 我的代码与链接上的代码很相似。 我的应用程序类别:
namespace MyApp.Library.Droid
{
public class SessionApplication : Application
{
private static int _userID;
private static string _email;
private static string _firstName;
private static string _lastName;
public override void OnCreate() {
base.OnCreate();
_userID=0;
_email=null;
_firstName = null;
_lastName = null;
}
public static int UserID
{
get { retu`enter code here`rn _userID; }
set { _userID=value; }
}
public static string Email
{
get { return _email; }
set { _email=value; }
}
public static string FirstName
{
get { return _firstName; }
set { _firstName=value; }
}
public static string LastName
{
get { return _lastName; }
set { _lastName=value; }
}
}
}
我的Android清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="myapp.ui.droid">
<uses-sdk />
<application android:label="myapp.ui.droid" android:name="myapp.library.droid.SessionApplication">
</application>
</manifest>
我的代码编译,但随后它运行引发此异常。 [MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] System.NotSupportedException:无法从本地句柄中激活MyApp.Library.Droid.SessionApplication类型的实例a2600019 ---> System.MissingMethodException:找不到用于MyApp.Library.Droid的构造函数.SessionApplication ::。ctor(System.IntPtr,Android.Runtime.JniHandleOwnership)---> Java.Interop.JavaLocationException:抛出了类型'Java.Interop.JavaLocationException'的异常。
我会感谢您的帮助。