What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ?  
Author Message
Pi314159





PostPosted: .NET Base Class Library, What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ? Top

I'm new to appdomain programming and I have no experience with COM+. Could you please tell me what "unwrap" is

Thank you very much.




.NET Development13  
 
 
CommonGenius.com





PostPosted: .NET Base Class Library, What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ? Top

From the MSDN documentation for CreateInstanceFromAndUnwrap: "This is a convenience method that combines CreateInstanceFrom and ObjectHandle.Unwrap."

CreateInstanceFrom returns an ObjectHandle reference, which wraps the underlying object. This ObjectHandle can be passed around, but to actually use the object you have created, you have to Unwrap it. CreateInstanceFromAndUnwrap combines these two methods.



 
 
Peca55





PostPosted: .NET Base Class Library, What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ? Top

Oh, your link don’t work. Try System.AppDomain.CreateInstanceFrom if you are interested.



 
 
Pi314159





PostPosted: .NET Base Class Library, What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ? Top

I see. Anyway, what is the advantage of ObjectHandle In which cases that we need ObjectHandle Does it has something to do with lifetime management in remote machine

 
 
CommonGenius.com





PostPosted: .NET Base Class Library, What is the difference between AppDomain.CreateInstanceFrom and AppDomain.CreateInstanceFromAndUnwrap ? Top

From the MSDN documentation for ObjectHandle:

"The ObjectHandle class is used to pass an object (in a wrapped state) between multiple application domains without loading the metadata for the wrapped object in each AppDomain through which the ObjectHandle travels. Thus, the ObjectHandle class gives the caller control of when the Type of the remote object is loaded into a domain."