[Mono-dev] Mixed Mode Assemblies

Jonathan Pryor jonpryor at vt.edu
Thu Jul 7 16:34:59 EDT 2011

On Jul 7, 2011, at 11:55 AM, arkain wrote:
> I understand the reasons why the developers chose to leave out support for
> developing mixed-mode assemblies using mono: the lack of cross-platform
> compatibility in such assemblies. However, I would argue that such things
> are not a consideration for those who would choose to develop such
> assemblies.

Mono supports mixed mode assemblies on Windows:


	"Mixed-mode assemblies are experimentally supported only on Windows..."

Mono can't support mixed-mode assemblies on any other platform, for a simple reason: in order for a mixed-mode assembly to be really useful, it needs to be loadable as a native library on the platform. This works on Windows because assemblies are PE/COFF files, and Windows dynamic link libraries are PE/COFF, so everything Just Works.

But try using dlopen(3) on Linux to load an assembly, and dlopen(3) will (rightfully) fail -- Linux wants ELF, not PE. There's a rather fundamental file format difference here.

That said there are efforts to improve the Mono/C++ interop story, e.g. via COM interop (which does work on Linux):


There was a GSOC project last year to improve C++/Mono interop, and Andreia Gaita presented on it:


There is also a current GSOC project:


So hopefully things will keep improving, but note that the above C++/mono interop techniques are _not_ "mixed mode assemblies." (XP)COM is a binary standard (via virtual function tables) which works quite nicely with dlopen(3)/etc., while the current C++ work can be thought of as an elaborate P/Invoke-like solution for C++ code.

 - Jon

More information about the Mono-devel-list mailing list