System.TypeLoadException:无法加载类型

在最近升级到Xamarin Studio 6和Mono 4.4.0.182(运行于OSX 10.10.5)之后,我们发现我们的应用程序不再运行(Asp.NET MVC / Razor网站)。 该解决方案确实编译正确,但。
我们尝试恢复到以前的版本 - Xamarin Studio 5.10.3和Mono 4.3.2,我们的应用程序仍然无法正常运行。 更新之前,完全相同的应用程序正常工作。
没有其他环境/代码更改已完成,并且重新启动也无效。

更新后生成错误。

第一个错误 (在应用程序启动时): System.Reflection.ReflectionTypeLoadException
这由SimpleInjector Container.RegisterPackages()触发。 这是Xamarin / Mono更新之前的工作,并没有应用/制作任何代码更改/包更新。

Could not load type 'System.Net.HttpListener' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Net.HttpListenerPrefixCollection' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Net.HttpWebRequest' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Net.Security.SslStream' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.Net.WebSockets.ClientWebSocket' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

堆栈跟踪

at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool) at System.Reflection.Assembly.GetExportedTypes () [0x00000] in /private/tmp/source-mono-4.3.2/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/Assembly.cs:407 at SimpleInjector.PackageExtensions.GetExportedTypesFrom (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
at SimpleInjector.PackageExtensions+<>c.<RegisterPackages>b__1_0 (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<SelectManyIterator>c__Iterator5`3[TSource,TCollection,TResult].MoveNext () [0x00059] in <filename unknown>:0
at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00078] in <filename unknown>:0
at System.Linq.Buffer`1[TElement]..ctor (IEnumerable`1 source) [0x00087] in <filename unknown>:0
at System.Linq.Enumerable.ToArray[TSource] (IEnumerable`1 source) [0x00011] in <filename unknown>:0
at SimpleInjector.PackageExtensions.RegisterPackages (SimpleInjector.Container container, IEnumerable`1 assemblies) [0x000f0] in <filename unknown>:0
at SimpleInjector.PackageExtensions.RegisterPackages (SimpleInjector.Container container) [0x0002f] in <filename unknown>:0
at MyApplication.Web.UI.MvcApplication.InitializeContainer (SimpleInjector.Container container) [0x00003] in /Users/*sanitized*/MyApplication.Web.UI/Global.asax.cs:57  

第二个错误 (页面重新加载和任何后续页面请求之后): System.ArgumentException具有相同键的项目已添加。
这是在我们的App_Start / RouteConfig.cs文件中引用了一个System.Web.Mvc.RouteCollectionExtensions.MapRoute调用(从Global.asax.cs,Application_Start中依次调用),指出该文件至少调用了两次。 再次,这是最近Xamarin / Mono更新之前的工作。

任何人都可以提供任何协助和/或建议吗?

编辑
回到单声道4.2.4.4,错误消失了。 看起来在引入这个bug的某个时候,4.3.2引入了一个变化。


我有一个类似的问题:

无法从程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Net.HttpListener'

我解决了将Mono.Security添加到可执行项目并重建它的问题。 希望这可以帮助

链接地址: http://www.djcxy.com/p/34777.html

上一篇: System.TypeLoadException: Could not load types

下一篇: JavaFX PrintAPI wrong PaperSource