7

After recently upgrading to Xamarin Studio 6 and Mono 4.4.0.182 (running on OSX 10.10.5) we found that our application no longer runs (Asp.NET MVC/Razor website). The solution does compile correctly however.
We've tried reverting back to the previous versions which did work - Xamarin Studio 5.10.3 and Mono 4.3.2, and our application still does not run correctly. The exact same application was working fine prior to the update.
No other environment/code changes have been made, and restarts have also not worked.

Errors being generated after the update.

1st Error (on application start): System.Reflection.ReflectionTypeLoadException
This is being triggered by SimpleInjector Container.RegisterPackages(). This was working prior to the Xamarin/Mono update, and no code changes/package updates have been applied/made.

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'. 

Stacktrace

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 

2nd Error (After page reload and any subsequent page requests): System.ArgumentException An item with the same key has already been added.
This is referencing a System.Web.Mvc.RouteCollectionExtensions.MapRoute call in our App_Start/RouteConfig.cs file (called in turn from Global.asax.cs, Application_Start), indicating that this file is being called at least twice. Again, this was working prior to the recent Xamarin/Mono update.

Can anyone provide any assistance and/or suggestions?

EDIT
Rolled back to Mono 4.2.4.4, and the error has gone away. Looks like there has been a change introduced into 4.3.2 at some point that has introduced this bug.

3
  • If reflecting over assemblies and types is a problem in Mono, you can easily remove Simple Injector's packages feature and instead do this without reflection. The packages feature is only really useful for highly dynamic plug-in based applications anyway. Commented Jun 13, 2016 at 4:59
  • Same thing happened to me. Still could not find a solution! Commented Jun 14, 2016 at 4:25
  • 1
    I also reverted back to 4.2.4.4 and it works. Commented Jun 14, 2016 at 4:55

1 Answer 1

3

I had a similar issue:

Could not load type 'System.Net.HttpListener' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I solved adding Mono.Security to the executable project and rebuilding it. Hope this helps

Sign up to request clarification or add additional context in comments.

2 Comments

how did you do it?
I referenced the assembly from the GAC in the main executable project using Xamarin Studio IDE.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.