[Mono-list] AppDomain.CreateInstanceAndUnwrap

Gonzalo Paniagua Javier gonzalo@ximian.com
Sat, 24 Jan 2004 10:48:29 +0100

El vie, 23-01-2004 a las 23:58, Marco Canini escribió:
> I've a question related to AppDomain.CreateInstanceAndUnwrap
> Such method invokes Activator.CreateInstance(string, string) which
> return an ObjectHandle and when unwrapped the reference to the created
> object.
> What I don't understand is if the newly created object lives in the
> context of the AppDomain (current) from which i called
> my2AppDomain.CreateInstanceAndUnwrap or the object lives inside
> my2AppDomain context where my2AppDomain != current AppDomain and the
> object reference returned in current AppDomain is a proxy to it.
> I think it's the first by considering that Activator.CreateInstance is
> called from current AppDomain but since the msdn documentation doesn't
> help me too much I ask to you guys.
> Any help is appreciated.

If you do my2AppDomain.CreateInstanceAndUnwrap (x, y), the new object is
created in my2AppDomain, not the current one. Then it's unwrapped and
what you get in the current domain is a proxy (for MarshalByRefObjects).