RemotingServices.Unmarshal 方法

定義

轉換指定的 ObjRef 為 Proxy 物件。

多載

Unmarshal(ObjRef)

取得 ObjRef,並利用它建立 Proxy 物件。

Unmarshal(ObjRef, Boolean)

取得 ObjRef,並利用它建立 Proxy 物件,同時將它修改為伺服器上的型別。

Unmarshal(ObjRef)

取得 ObjRef,並利用它建立 Proxy 物件。

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,表示正在用來建立 Proxy 的遠端物件。

傳回

指定 ObjRef 所表示的物件 Proxy。

屬性

例外狀況

objectRef 參數中指定的 ObjRef 執行個體語式不正確。

至少有一個呼叫堆疊中較高的呼叫端,不具有設定遠端類型和通道的使用權限。

範例

下列程式代碼範例示範如何取消復原 物件。

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是物件可串行化的表示法,用來跨應用程式域界限傳輸對象參考。 ObjRef建立對象的 稱為封送處理。 ObjRef可以透過通道傳輸到另一個應用程式域, (可能在另一個進程或計算機上) 。 在其他應用程式域中, ObjRef 必須剖析 ,才能為物件建立 Proxy,通常連接到實際物件。 這項作業稱為「取消封擷取」。 在取消封存期間,會 ObjRef 剖析 以擷取遠端物件的方法資訊,並同時建立透明 Proxy 和 RealProxy 物件。 剖析 ObjRef 的內容會在向 Common Language Runtime 註冊透明 Proxy 之前新增至透明 Proxy。

ObjRef包含可描述Type要封送處理之物件的 和類別、可唯一識別特定物件實例的 URI,以及如何連線到物件所在遠端細分的相關信息。

另請參閱

適用於

Unmarshal(ObjRef, Boolean)

取得 ObjRef,並利用它建立 Proxy 物件,同時將它修改為伺服器上的型別。

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,表示正在用來建立 Proxy 的遠端物件。

fRefine
Boolean

若要修改 Proxy 為伺服器上的型別,則為 true,否則為 false

傳回

指定 ObjRef 所表示的物件 Proxy。

屬性

例外狀況

objectRef 參數中指定的 ObjRef 執行個體語式不正確。

至少有一個呼叫堆疊中較高的呼叫端,不具有設定遠端類型和通道的使用權限。

備註

ObjRef是物件可串行化的表示法,用來跨應用程式域界限傳輸對象參考。 ObjRef建立對象的 稱為封送處理。 ObjRef可以透過通道傳輸到另一個應用程式域, (可能在另一個進程或計算機上) 。 在其他應用程式域中, ObjRef 必須剖析 ,才能為物件建立 Proxy,通常連接到實際物件。 這項作業稱為「取消封擷取」。 在取消封存期間,會 ObjRef 剖析 以擷取遠端物件的方法資訊,並同時建立透明 Proxy 和 RealProxy 物件。 剖析 ObjRef 的內容會在向 Common Language Runtime 註冊透明 Proxy 之前新增至透明 Proxy。

ObjRef包含可描述Type要封送處理之物件的 和類別、可唯一識別特定物件實例的 URI,以及如何連線到物件所在遠端細分的相關信息。

第一次建立時,Proxy 的類型為 MarshalByRefObject。 當您將它轉換成不同類型的時,遠端基礎結構會持續追蹤最常用的類型,以避免不必要地載入類型。

另請參閱

適用於