System.TypeLoadException无法加载类型CategoryActivity

时间:2016-01-23 15:38:53

标签: xamarin mono xamarin.android typeloadexception

我编写了一个带有以下定义的Activity类

[Activity(Label = "Courses", MainLauncher = true, Icon = "@drawable/icon")]
public class CategoryActivity : ListActivity
{
    CourseCategoryManager _courseCategoryManager;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        _courseCategoryManager = new CourseCategoryManager();
        ListAdapter = new CourseCategoryManagerAdapter(this,
            global::Android.Resource.Layout.SimpleListItem1,
            _courseCategoryManager);
    }

 }

此活动类的目的是将所有类别显示为列表项。

但是当我运行应用程序时,它会返回以下异常:

01-23 14:27:19.157 E/MonoDroid( 2137): Could not load type 'Courses.Android.CategoriesActivity, Courses.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Skipping JNI registration of type 'md5ba6caf9a9061d0cbb25c0daaef535be4/CategoriesActivity'.
An unhandled exception occured.

01-23 14:27:20.371 I/art     ( 2137): Thread[2,tid=2143,WaitingInMainSignalCatcherLoop,Thread*=0xaf478400,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3
01-23 14:27:21.224 I/art     ( 2137): Wrote stack traces to '/data/anr/traces.txt'
01-23 14:27:23.305 I/MonoDroid( 2137): UNHANDLED EXCEPTION:
01-23 14:27:23.526 I/MonoDroid( 2137): System.TypeLoadException: Could not load type 'Courses.Android.CategoriesActivity, Courses.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' from assembly ''.
01-23 14:27:23.526 I/MonoDroid( 2137):   at (wrapper managed-to-native) System.Type:internal_from_name (string,bool,bool)
01-23 14:27:23.527 I/MonoDroid( 2137):   at System.Type.GetType (System.String typeName, Boolean throwOnError) [0x00011] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/mcs/class/corlib/ReferenceSources/Type.cs:57 
01-23 14:27:23.527 I/MonoDroid( 2137):   at Java.Interop.TypeManager.n_Activate (IntPtr jnienv, IntPtr jclass, IntPtr typename_ptr, IntPtr signature_ptr, IntPtr jobject, IntPtr parameters_ptr) [0x0007b] in /Users/builder/data/lanes/2098/3efa14c4/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:145 
01-23 14:27:23.527 I/MonoDroid( 2137):   at (wrapper dynamic-method) System.Object:90d2a13e-584b-4a05-a439-c9d6ba401669 (intptr,intptr,intptr,intptr,intptr,intptr)
01-23 14:27:23.644 W/art     ( 2137): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
An unhandled exception occured.

01-23 14:27:24.452 E/mono    ( 2137): 
01-23 14:27:24.452 E/mono    ( 2137): Unhandled Exception:
01-23 14:27:24.452 E/mono    ( 2137): System.TypeLoadException: Could not load type 'Courses.Android.CategoriesActivity, Courses.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' from assembly ''.
01-23 14:27:24.452 E/mono    ( 2137):   at (wrapper dynamic-method) System.Object:90d2a13e-584b-4a05-a439-c9d6ba401669 (intptr,intptr,intptr,intptr,intptr,intptr)
01-23 14:27:24.452 E/mono    ( 2137):   at (wrapper native-to-managed) System.Object:90d2a13e-584b-4a05-a439-c9d6ba401669 (intptr,intptr,intptr,intptr,intptr,intptr)
01-23 14:27:24.453 E/mono-rt ( 2137): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Courses.Android.CategoriesActivity, Courses.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' from assembly ''.
01-23 14:27:24.453 E/mono-rt ( 2137):   at (wrapper dynamic-method) System.Object:90d2a13e-584b-4a05-a439-c9d6ba401669 (intptr,intptr,intptr,intptr,intptr,intptr)
01-23 14:27:24.453 E/mono-rt ( 2137):   at (wrapper native-to-managed) System.Object:90d2a13e-584b-4a05-a439-c9d6ba401669 (intptr,intptr,intptr,intptr,intptr,intptr)
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1

1 个答案:

答案 0 :(得分:0)

从您的设备上卸载APK,清理项目并在手机或模拟器上进行编译,以解决问题。

相关问题