[Mono-dev] Embedded mono, issues with specific v4.0 I triesruntime versions and System.Runtime.CompilerServices.ExtensionAttribute

Jean-Michel.Perraud at csiro.au Jean-Michel.Perraud at csiro.au
Sat Jan 19 06:52:24 UTC 2013


A project of mine using Mono embedding started displayed issues when I started to execute managed code with extension methods. I've isolated the issue and can submit one or two bug reports, but in the meantime advice/insight is welcome. Being stuck, I'd gladly take any suggestion on a workaround. 


* One class library, with a class with an extension method
* A simple exe program calling this library
* A  visual c++ project, embedding Mono, to execute code in the previous two managed assemblies 
* Both assemblies compiled from VS2012, targeting .NET 4.0 (*not* 4.5)
* Mono JIT compiler version 3.0.1 on Windows (observed identical issues on a Debian box)

* The program runs as expected from the command prompt
* With embedded mono, if I initialise the JIT with specific version "v4.0.30128", the runtime seems to init correctly, but executing code in the assembly fails, with the following console output:
   * "Missing method .ctor in assembly C:\blah\LibWithExtMethods.dll, type System.Runtime.CompilerServices.ExtensionAttribute"
   * "Can't find custom attr constructor image: C:\blah\LibWithExtMethods.dll mtoken: 0x0a000011"
* I suspect that the successful run from the command line is because the 4.5 runtime is used. So be it, happy to upgrade. However, requesting "v4.0.30319" (the 4.5 runtime) or letting mono guess the runtime from the .exe, I get an Access violation, occurring inside mono_alloc_special_static_data (called indirectly from mono_thread_pool_init)

The ExtensionAttribute class has changed assembly between .net 4.0 and 4.5, from System.Core to mscorlib. This seems to have cause quite a few issues, including for some Mono users. The conter-intuitive thing is that requesting a Mono v4.0 runtime to run these v4.0 assemblies fails.

More information about the Mono-devel-list mailing list