Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 启动时TypeLoadException_C#_Xamarin_Xamarin.android_Mvvmcross_Portable Class Library - Fatal编程技术网

C# 启动时TypeLoadException

C# 启动时TypeLoadException,c#,xamarin,xamarin.android,mvvmcross,portable-class-library,C#,Xamarin,Xamarin.android,Mvvmcross,Portable Class Library,最近开始使用Xamarin和MvvmCross。忙着建立我的第一个项目。创建了my.Core项目和ViewModel,并在Visual Studio中安装了Nuget软件包。创建了my.Droid项目,安装了Nuget软件包。创建了我的第一个视图,现在正在尝试运行应用程序。但是,我得到以下例外情况: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Cirrious.Mv

最近开始使用Xamarin和MvvmCross。忙着建立我的第一个项目。创建了my.Core项目和ViewModel,并在Visual Studio中安装了Nuget软件包。创建了my.Droid项目,安装了Nuget软件包。创建了我的第一个视图,现在正在尝试运行应用程序。但是,我得到以下例外情况:

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Cirrious.MvvmCross.Binding.Droid'.

Full stacktrace:
W/        ( 1438): Missing method .ctor in assembly /data/data/XamTest.Droid/files/.__override__/Cirrious.MvvmCross.Droid.dll, type System.Runtime.CompilerServices.ExtensionAttribute
W/        ( 1438): Can't find custom attr constructor image: /data/data/XamTest.Droid/files/.__override__/Cirrious.MvvmCross.Droid.dll mtoken: 0x0a000012
Unhandled Exception:

System.TypeLoadException: 
E/mono    ( 1438): 
E/mono    ( 1438): Unhandled Exception:
E/mono    ( 1438): System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Cirrious.MvvmCross.Droid'.
E/mono    ( 1438): at XamTest.Droid.SplashScreen..ctor () [0x00000] in c:\Dev\XamTest\XamTest.Droid\SplashScreen.cs:16
E/mono    ( 1438): at (wrapper dynamic-method) object.38e61b4f-1913-46a5-ba4a-75980457a823 (intptr,object[]) <IL 0x00018, 0x00053>
E/mono    ( 1438): at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) [0x0006a] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:141
E/mono    ( 1438): at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) <IL 0x0001e, 0x000a3>
E/mono    ( 1438): 
I/mono    ( 1438): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Cirrious.MvvmCross.Droid'.
I/mono    ( 1438): at XamTest.Droid.SplashScreen..ctor () [0x00000] in c:\Dev\XamTest\XamTest.Droid\SplashScreen.cs:16
I/mono    ( 1438): at (wrapper dynamic-method) object.38e61b4f-1913-46a5-ba4a-75980457a823 (intptr,object[]) <IL 0x00018, 0x00053>
I/mono    ( 1438): at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) [0x0006a] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:141
I/mono    ( 1438): at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) <IL 0x0001e, 0x000a3>
I/mono    ( 1438): 
无法从程序集“cirrial.MvvmCross.Binding.Droid”加载类型“System.Runtime.CompilerServices.ExtensionAttribute”。
完整堆栈跟踪:
W/(1438):在assembly/data/data/XamTest.Droid/files/.\uuuu override.\uuuu/cirries.MvvmCross.Droid.dll中缺少方法.ctor,键入System.Runtime.CompilerServices.ExtensionAttribute
W/(1438):找不到自定义attr构造函数映像:/data/data/XamTest.Droid/files/
未处理的异常:
System.TypeLoadException:
E/mono(1438):
E/mono(1438):未处理的异常:
E/mono(1438):System.TypeLoadException:无法从程序集“Cirrious.MvvmCross.Droid”加载类型“System.Runtime.CompilerServices.ExtensionAttribute”。
E/mono(1438):位于c:\Dev\XamTest\XamTest.Droid\SplashScreen.cs:16中的XamTest.Droid.SplashScreen..ctor()[0x00000]
E/mono(1438):at(包装器动态方法)对象38e61b4f-1913-46a5-ba4a-75980457a823(intptr,对象[])
E/mono(1438):在Java.Interop.TypeManager.n_激活(intptr,intptr,intptr,intptr,intptr,intptr,intptr)[0x0006a]in/Users/builder/data/lanes/monodroid-lion-bigssplash/0e0e51f9/source/monodroid/src/mono.Android/src/Java.Interop/TypeManager.cs:141
E/mono(1438):at(托管的本机包装器)Java.Interop.TypeManager.n_激活(intptr、intptr、intptr、intptr、intptr)
E/mono(1438):
I/mono(1438):[错误]未处理的致命异常:System.TypeLoadException:无法从程序集'Cirrious.MvvmCross.Droid'加载类型'System.Runtime.CompilerServices.ExtensionAttribute'。
I/mono(1438):位于c:\Dev\XamTest\XamTest.Droid\SplashScreen.cs:16中的XamTest.Droid.SplashScreen..ctor()[0x00000]
I/mono(1438):at(包装器动态方法)对象38e61b4f-1913-46a5-ba4a-75980457a823(intptr,对象[])
I/mono(1438):在Java.Interop.TypeManager.n_激活(intptr,intptr,intptr,intptr,intptr,intptr,intptr)[0x0006a]in/Users/builder/data/lanes/monodroid-lion-bigssplash/0e0e51f9/source/monodroid/src/mono.Android/src/Java.Interop/TypeManager.cs:141
I/mono(1438):at(托管的本机包装器)Java.Interop.TypeManager.n_激活(intptr、intptr、intptr、intptr、intptr、intptr)
I/mono(1438):
有什么想法吗

我需要提到的是,当我在Xamarin.Studio中打开我的解决方案时,对核心库的引用显示为一个错误

(-不兼容的目标框架(.Net可移植子集(.Net for Windows Store、.Net framework 4.5、Silverlight 4、Windows Phone 7.5)。)


这可能只是另一个问题,与异常无关。

问题与我安装的热金枪鱼启动包版本有关。我安装了3.0.12版

当我将位于packages\MvvmCross.HotTuna.MvvmCrossLibraries.3.0.12\lib\MonoAndroid16的cirrius.MVVM和cirrius.MVVM.Droid dll替换为Hot Turna Starter pack V3.0.9中的dll时,一切都开始正常工作。(我还测试了3.0.4,它也正常工作)

我没有测试V3.0.10和V3.0.11。我也测试了V3.0.13测试版,但它仍然是坏的

  • 您是否正在使用stable分支的Visual Studio 2012和Xamarin最新版本

  • 重要信息:在Visual Studio中,转到左侧的“工具”菜单\扩展和更新\更新选项卡,确保您拥有最新的NuGet manager

  • 我建议您重新开始一个新的测试项目,并严格遵循以下步骤:

    a) 创建一个名为MyApp.Droid的新Android应用程序,以及一个新的PCL项目MyApp.Core(目标“.NET Framework 4.5”和“Windows Phone 7.5及以上版本”-这些是MVVMCross使用的最低框架版本

    b) 将MyApp.Core作为项目引用添加到MyApp.Droid

    c) 使用NuGet安装“MVVMCross热金枪鱼启动包”。确保已选择稳定分支(NuGet窗口顶部有一个组合框)

    一切都应该编译并运行良好


  • 当我遇到同样的问题时,以下是对我有效的方法:

    当我更新mvvmCross时,我仍然使用旧版本的Xamarin,它使用旧版本的monodroid。更新Xamarin(新版本使用Monodroid3)为我解决了这个问题


    希望这有助于

    更新以包含完整的stacktrace。v3.0.9与今天的主要区别在于xamarin.android版本的更改-到使用mono3的新版本-这与xamarin相比是“稳定的”。您使用的是什么xamarin版本?谢谢您的OpCoder。这些正是我遵循的步骤,但正如其他人所说,“你的电脑里有龙”。我最终解决了这个问题,用一个旧版本替换了Cirrius二进制文件(不是Hot Tunar Starter pack当前安装的3.0.12版本)。没有理由使用旧版本。你应该用最后一个稳定的。你瞄准了错误的框架