AppDomains .NET C#

Joined
Jun 24, 2009
Messages
1
Reaction score
0
Does anyone no the difference in between the two follow operations?
(I'm omitting details)

public classMarshalByRefType : MarshalByRefObject
{
... class info
}


1. Uses AppDomain.CreateInstanceAndUnwrap(..)

AppDomain domain2 = AppDomain.CreateDomain("D2", null, null);
MarshalByRefType mbrt = (MarshalByRefType)domain2.CreateInstanceAndUnwrap("assemblyname", typeof(MarshalByRefType).FullName);

2. Uses Assembly.CreateInstance(..)

AppDomain domain2 = AppDomain.CreateDomain("D2", null, null);
Assembly assembly = domain2.Load("assemblyname");
MarshalByRefType mbrt = (MarshalByRefType)assembly.CreateInstance(typeof(MarshalByRefType ).FullName);

The only difference that I can see is that AppDomain.CreateInstanceAndUnwrap(..)
forces your type to be serializable or derived from MarshalByRefObject.
Does that mean that the second method really doesnt create the new object
in the new AppDomain?

Thanks in advance
Brandon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top