[Mono-dev] [Mono-list] Mono embedded : EXC_BAD_ACCESS calling mono_object_hash() on MonoDomain *

Jonathan Mitchell lists at mugginsoft.com
Tue Nov 22 11:12:47 UTC 2016

> On 22 Nov 2016, at 00:45, Jon Purdy <jopur at microsoft.com> wrote:
> A MonoDomain is not a MonoObject—they have very different internal representations. MonoDomain does internally contain a field (“domain”) of type MonoAppDomain*, which is compatible with MonoObject*, but I don’t think we expose this. What problem are you trying to solve?
Thanks for that. It sounds like MonoAppDomain is what I am after.

I am trying to register for the System.AppDomain.UnhandledException event.
I use an Obj-C bridge (https://github.com/ThesaurusSoftware/Dubrovnik) to hook up managed events to static native callback functions.
In order to do this I need a MonoObject * representation of the managed object.

It looks as if the public embedded API is deficient in this case.
We do have 

MONO_API MonoDomain *
mono_domain_from_appdomain (MonoAppDomain *appdomain);

but there is no function the supplies MonoDomain->domain.

I think this means that System.AppDomain is effectively off limits for the embedded API as without access to a MonoObject * we cannot query methods etc or invoke the runtime.

At a pinch I could do what I need in managed code but I will try and add the required accessor to appdomain.c and see how I get on.

More information about the Mono-devel-list mailing list