- 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
(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