RemotingServices.Unmarshal 方法

定义

将给定的 ObjRef 转换为代理对象。Converts a given ObjRef into a proxy object.

重载

Unmarshal(ObjRef)

接受 ObjRef 并从它创建一个代理对象。Takes a ObjRef and creates a proxy object out of it.

Unmarshal(ObjRef, Boolean)

接受 ObjRef 并从它创建一个代理对象,然后将其精炼为服务器上的类型。Takes a ObjRef and creates a proxy object out of it, refining it to the type on the server.

Unmarshal(ObjRef)

接受 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

参数

objectRef
ObjRef

ObjRef,它代表正在为其创建代理的远程对象。The ObjRef that represents the remote object for which the proxy is being created.

返回

Object

给定的 ObjRef 所代表对象的代理。A proxy to the object that the given ObjRef represents.

属性

例外

objectRef 参数中指定的 ObjRef 实例不是格式良好的。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.

示例

下面的代码示例演示如何取消封送对象。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.")

注解

ObjRef是用于跨应用程序域边界传输对象引用的对象的可序列化表示形式。A ObjRef is a serializable representation of an object used to transfer an object reference across an application domain boundary. ObjRef为对象创建是封送处理。Creating a ObjRef for an object is known as marshaling. ObjRef可以通过通道传输到另一个应用程序域中, (可能) 的其他进程或计算机上。The ObjRef can be transferred through a channel into another application domain (possibly on another process or computer). 在另一个应用程序域中, ObjRef 必须对进行分析,以便为该对象创建一个代理,该代理通常连接到实际对象。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. 在取消封送过程中,将对 ObjRef 进行分析以提取远程对象的方法信息,同时还 RealProxy 会创建透明代理和对象。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. 在将 ObjRef 透明代理注册到公共语言运行时之前,分析的内容会添加到透明代理。The content of the parsed ObjRef is added to the transparent proxy before the transparent proxy is registered with the common language runtime.

ObjRef包含描述 Type 正在被封送处理的对象的和类的信息、唯一标识特定对象实例的 URI 以及有关如何到达对象所在的远程处理细分的通信相关信息。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.

另请参阅

适用于

Unmarshal(ObjRef, Boolean)

接受 ObjRef 并从它创建一个代理对象,然后将其精炼为服务器上的类型。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

参数

objectRef
ObjRef

ObjRef,它代表正在为其创建代理的远程对象。The ObjRef that represents the remote object for which the proxy is being created.

fRefine
Boolean

如果为 true,则将代理精炼为服务器上的类型;否则为 falsetrue to refine the proxy to the type on the server; otherwise, false.

返回

Object

给定的 ObjRef 所代表对象的代理。A proxy to the object that the given ObjRef represents.

属性

例外

objectRef 参数中指定的 ObjRef 实例不是格式良好的。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.

注解

ObjRef是用于跨应用程序域边界传输对象引用的对象的可序列化表示形式。A ObjRef is a serializable representation of an object used to transfer an object reference across an application domain boundary. ObjRef为对象创建是封送处理。Creating a ObjRef for an object is known as marshaling. ObjRef可以通过通道传输到另一个应用程序域中, (可能) 的其他进程或计算机上。The ObjRef can be transferred through a channel into another application domain (possibly on another process or computer). 在另一个应用程序域中, ObjRef 必须对进行分析,以便为该对象创建一个代理,该代理通常连接到实际对象。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. 在取消封送过程中,将对 ObjRef 进行分析以提取远程对象的方法信息,同时还 RealProxy 会创建透明代理和对象。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. 在将 ObjRef 透明代理注册到公共语言运行时之前,分析的内容会添加到透明代理。The content of the parsed ObjRef is added to the transparent proxy before the transparent proxy is registered with the common language runtime.

ObjRef包含描述 Type 正在被封送处理的对象的和类的信息、唯一标识特定对象实例的 URI 以及有关如何到达对象所在的远程处理细分的通信相关信息。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.

第一次创建时,代理的类型为 MarshalByRefObjectWhen 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.

另请参阅

适用于