Mono - System.TypeLoadException:无法加载类型

Ale*_*unn 7 mono typeloadexception exception simple-injector xamarin

在最近升级到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'.
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

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  
Run Code Online (Sandbox Code Playgroud)

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

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

EDIT
回滚到Mono 4.2.4.4,错误消失了.看起来在4.3.2中引入了一个已经引入了这个bug的变化.

小智 3

我有一个类似的问题:

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

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