[Mono-list] Assembly.GetExecutingAssembly() not working in embedded mono?

Robert Jordan robertj at gmx.net
Mon Feb 18 15:21:02 UTC 2013


On 16.02.2013 23:41, nelson wrote:
> I'm trying to embed mono in a c++ executable, and mono crashes on
> Assembly.GetExecutingAssembly. Any idea of what I missed ?
>

Some reflection methods don't work correctly if they are unable to
walk managed stack frames. When mono_runtime_invoke () is called
on such a method, no managed stack frames exist and these methods
are simply crashing.

You can work around this issue by providing helpers for these
methods:

[MethodImpl(MethodImplOptions.NoInlining)]
public static Assembly GetExecutingAssembly ()
{
	return Assembly.GetExecutingAssembly ();
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static Assembly GetCallingAssembly ()
{
	return Assembly.GetCallingAssembly ();
}

You may want to file a bug, but I believe the issue is by design.

Robert




More information about the Mono-list mailing list