Bewerken

Delen via


RemotingServices.Unmarshal Method

Definition

Converts a given ObjRef into a proxy object.

Overloads

Unmarshal(ObjRef)

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

Unmarshal(ObjRef, Boolean)

Takes a ObjRef and creates a proxy object out of it, refining it to the type on the server.

Unmarshal(ObjRef)

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

public:
 static System::Object ^ Unmarshal(System::Runtime::Remoting::ObjRef ^ objectRef);
public static object Unmarshal (System.Runtime.Remoting.ObjRef objectRef);
[System.Security.SecurityCritical]
public static object Unmarshal (System.Runtime.Remoting.ObjRef objectRef);
static member Unmarshal : System.Runtime.Remoting.ObjRef -> obj
[<System.Security.SecurityCritical>]
static member Unmarshal : System.Runtime.Remoting.ObjRef -> obj
Public Shared Function Unmarshal (objectRef As ObjRef) As Object

Parameters

objectRef
ObjRef

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

Returns

A proxy to the object that the given ObjRef represents.

Attributes

Exceptions

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

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

Examples

The following code example demonstrates how to unmarshal an object.

ChannelServices::RegisterChannel( gcnew HttpChannel );

SampleService ^ objectSample = (SampleService^)( Activator::GetObject( SampleService::typeid,
   "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." );
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.");
ChannelServices.RegisterChannel(New HttpChannel())

Dim objectSample As SampleService = CType(Activator.GetObject(GetType(SampleService), _ 
      "http://localhost:9000/MySampleService/SampleService.soap"), SampleService)

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

Dim objectSampleTwo As SampleTwo = CType(RemotingServices.Unmarshal(objRefSampleTwo), SampleTwo)

objectSampleTwo.PrintMessage("I successfully unmarshaled your ObjRef.  Thanks.")

Remarks

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.

See also

Applies to

Unmarshal(ObjRef, Boolean)

Takes a ObjRef and creates a proxy object out of it, refining it to the type on the server.

public:
 static System::Object ^ Unmarshal(System::Runtime::Remoting::ObjRef ^ objectRef, bool fRefine);
public static object Unmarshal (System.Runtime.Remoting.ObjRef objectRef, bool fRefine);
[System.Security.SecurityCritical]
public static object Unmarshal (System.Runtime.Remoting.ObjRef objectRef, bool fRefine);
static member Unmarshal : System.Runtime.Remoting.ObjRef * bool -> obj
[<System.Security.SecurityCritical>]
static member Unmarshal : System.Runtime.Remoting.ObjRef * bool -> obj
Public Shared Function Unmarshal (objectRef As ObjRef, fRefine As Boolean) As Object

Parameters

objectRef
ObjRef

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

fRefine
Boolean

true to refine the proxy to the type on the server; otherwise, false.

Returns

A proxy to the object that the given ObjRef represents.

Attributes

Exceptions

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

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

Remarks

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.

When first created, the proxy is of type MarshalByRefObject. As you cast it into different types, the remoting infrastructure keeps track of the most used type to avoid loading the type unnecessarily.

See also

Applies to