RemotingServices.Unmarshal Method (ObjRef)

Takes a ObjRef and creates a proxy object out of it.

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

public static Object Unmarshal(
	ObjRef objectRef
)

Parameters

objectRef
Type: System.Runtime.Remoting.ObjRef

The ObjRef that represents the remote object for which the proxy is being created.

Return Value

Type: System.Object
A proxy to the object that the given ObjRef represents.

ExceptionCondition
ArgumentException

The ObjRef instance specified in the objectRef parameter is not well-formed.

SecurityException

At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.

A ObjRef is a serializable representation of an object used to transfer an object reference across an application domain boundary. Creating a ObjRef for an object is known as marshaling. The ObjRef can be transferred through a channel into another application domain (possibly on another process or computer). Once in the other application domain, the ObjRef must be parsed to create a proxy for the object, generally connected to the real object. This operation is known as unmarshaling. During unmarshaling, the ObjRef is parsed to extract the method information of the remote object and both the transparent proxy and RealProxy objects are created. The content of the parsed ObjRef is added to the transparent proxy before the transparent proxy is registered with the common language runtime.

A ObjRef contains information that describes the Type and class of the object being marshaled, a URI that uniquely identifies the specific object instance, and communication related information about how to reach the remoting subdivision where the object is located.

The following code example demonstrates how to unmarshal an object.

ChannelServices.RegisterChannel(new HttpChannel());

SampleService objectSample = (SampleService)Activator.GetObject(typeof(SampleService), 
    "http://localhost:9000/MySampleService/SampleService.soap");

// The GetManuallyMarshaledObject() method uses RemotingServices.Marshal() 
// to create an ObjRef object for a SampleTwo object.
ObjRef objRefSampleTwo = objectSample.GetManuallyMarshaledObject();

SampleTwo objectSampleTwo = (SampleTwo)RemotingServices.Unmarshal(objRefSampleTwo);

objectSampleTwo.PrintMessage("ObjRef successfuly unmarshaled."); 

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft