ObjectHandle.Unwrap Method ()


Returns the wrapped object.

Namespace:   System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

public object Unwrap()

Return Value

Type: System.Object

The wrapped object.

Notes to Callers:

A ObjectHandle is a remoted MarshalByRefObject that is tracked by the remoting lifetime service. A call to the current method can fail if the lifetime lease on the ObjectHandle expires.

The following code example demonstrates how to activate an object in another AppDomain, retrieve a proxy to it with the Unwrap method, and use the proxy to access the remote object.

// Creates an instance of MyType defined in the assembly called ObjectHandleAssembly.
ObjectHandle obj = domain.CreateInstance("ObjectHandleAssembly", "MyType");

// Unwrapps the proxy to the MyType object created in the other AppDomain.
MyType testObj = (MyType)obj.Unwrap();

   Console.WriteLine("The unwrapped object is a proxy.");
   Console.WriteLine("The unwrapped object is not a proxy!");    

Console.Write("Calling a method on the object located in an AppDomain with the hash code ");

.NET Framework
Available since 1.1
Return to top