[Mono-list] Autofac 3.0.1 on Mono 3.0.5

Erik Schierboom e.schierboom at uci.ru.nl
Wed Feb 27 13:34:41 UTC 2013


I have been trying to get Autofac 3.0.1 working on Mono, but have so far 
been unsuccessful. When I try to run an application that references 
Autofac 3.0.1 on Mono 3.0.5, I get the following exception:

     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/mono/4.5/mscorlib.dll'.
     Mono: Image addref mscorlib[0x14ce2c70] -> 
/opt/mono-3.0.5/lib/mono/4.5/mscorlib.dll[0x14ce1ec0]: 2
     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/mono/4.5/mscorlib.dll'.
     Mono: Assembly Loader loaded assembly from location: 
'/opt/mono-3.0.5/lib/mono/4.5/mscorlib.dll'.
     Mono: Assembly mscorlib[0x14ce2c70] added to domain 
ConsoleApplication1.exe, ref_count=1
     Mono: Assembly Loader probing location: 'ConsoleApplication1.exe'.
     Mono: Image addref ConsoleApplication1[0x14d20230] -> 
/var/www/sites/erik/monoconsole/ConsoleApplication1.exe[0x14d1f4a0]: 2
     Mono: Assembly ConsoleApplication1[0x14d20230] added to domain 
ConsoleApplication1.exe, ref_count=1
     Mono: Assembly Loader loaded assembly from location: 
'ConsoleApplication1.exe'.
     Mono: Assembly Loader probing location: 'ConsoleApplication1.exe'.
     Mono: Assembly Ref addref ConsoleApplication1[0x14d20230] -> 
mscorlib[0x14ce2c70]: 2
     Mono: Assembly Loader probing location: 
'/var/www/sites/erik/monoconsole/Autofac.dll'.
     Mono: Image addref Autofac[0x14d269b0] -> 
/var/www/sites/erik/monoconsole/Autofac.dll[0x14d25c40]: 2
     Mono: Assembly Autofac[0x14d269b0] added to domain 
ConsoleApplication1.exe, ref_count=1
     Mono: Assembly Loader loaded assembly from location: 
'/var/www/sites/erik/monoconsole/Autofac.dll'.
     Mono: Assembly Ref addref ConsoleApplication1[0x14d20230] -> 
Autofac[0x14d269b0]: 2
     Mono: The request to load the retargetable assembly mscorlib 
v2.0.5.0 was remapped to mscorlib v4.0.0.0
     Mono: Assembly Ref addref Autofac[0x14d269b0] -> 
mscorlib[0x14ce2c70]: 3
     Mono: The request to load the retargetable assembly System.Core 
v2.0.5.0 was remapped to System.Core v4.0.0.0
     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/mono/gac/System.Core/4.0.0.0__7cec85d7bea7798e/System.Core.dll'.
     Mono: Assembly Loader probing location: 
'/var/www/sites/erik/monoconsole/System.Core.dll'.
     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/System.Core.dll'.
     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/mono/gac/System.Core/4.0.0.0__7cec85d7bea7798e/System.Core.exe'.
     Mono: Assembly Loader probing location: 
'/var/www/sites/erik/monoconsole/System.Core.exe'.
     Mono: Assembly Loader probing location: 
'/opt/mono-3.0.5/lib/System.Core.exe'.
     Mono: The following assembly referenced from 
/var/www/sites/erik/monoconsole/Autofac.dll could not be loaded:
          Assembly:   System.Core    (assemblyref_index=1)
          Version:    2.0.5.0
          Public Key: 7cec85d7bea7798e
     The assembly was not found in the Global Assembly Cache, a path 
listed in the MONO_PATH environment variable, or in the location of the 
executing assembly (/var/www/sites/erik/monoconsole/).

     Mono: Failed to load assembly Autofac[0x14d269b0]

     Mono: Could not load file or assembly 'System.Core, 
Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, 
Retargetable=Yes' or one of its dependencies.
     Missing method .ctor in assembly 
/var/www/sites/erik/monoconsole/Autofac.dll, type 
System.Runtime.CompilerServices.ExtensionAttribute
     Can't find custom attr constructor image: 
/var/www/sites/erik/monoconsole/Autofac.dll mtoken: 0x0a000015
     Hello!
     Mono: Unloading domain ConsoleApplication1.exe[0x2aaaab6f1cc0], 
assembly mscorlib[0x14ce2c70], ref_count=3
     Mono: Unloading domain ConsoleApplication1.exe[0x2aaaab6f1cc0], 
assembly ConsoleApplication1[0x14d20230], ref_count=1
     Mono: Unloading assembly ConsoleApplication1 [0x14d20230].
     Mono: Unloading image 
/var/www/sites/erik/monoconsole/ConsoleApplication1.exe [0x14d1f4a0].
     Mono: Unloading domain ConsoleApplication1.exe[0x2aaaab6f1cc0], 
assembly Autofac[0x14d269b0], ref_count=1
     Mono: Unloading assembly Autofac [0x14d269b0].
     Mono: Unloading image /var/www/sites/erik/monoconsole/Autofac.dll 
[0x14d25c40].
     Mono: Unloading assembly mscorlib [0x14ce2c70].
     Mono: Unloading image /opt/mono-3.0.5/lib/mono/4.5/mscorlib.dll 
[0x14ce1ec0].

There are several things to note. First, it appears that System.Core 
2.0.5.0 could not be loaded. Could this be due to Autofac 3.0.1 being a 
portable class library?

This problem also results in the second issue, where there is a Missing 
method .ctor in System.Runtime.CompilerServices.ExtensionAttribute. I 
have found some information about this problem, and it appears that this 
problem is due to the ExtensionAttribute class being moved from one DLL 
to another: 
http://www.lextm.com/2013/02/how-to-use-nuget-on-mono-part-iv.html

This problem can be reproduced as follows (see 
https://gist.github.com/ErikSchierboom/5047101):

  1. Create a .NET 4.0 console application
  2. Add a reference to Autofac 3.0.1 (e.g. through NuGet)
  3. Create an instance of the `ContainerBuilder` class
  4. Build the console application
  5. Run the console application under Mono

Does anyone have an idea on how to solve this problem?


More information about the Mono-list mailing list