ObjectHandle.Unwrap 메서드

정의

래핑된 개체를 반환합니다.

public:
 System::Object ^ Unwrap();
public:
 virtual System::Object ^ Unwrap();
public object? Unwrap();
public object Unwrap();
member this.Unwrap : unit -> obj
abstract member Unwrap : unit -> obj
override this.Unwrap : unit -> obj
Public Function Unwrap () As Object

반품

래핑된 개체입니다.

구현

예제

다음 코드 예제에서는 다른 AppDomain개체에서 개체를 활성화하고, 메서드를 사용하여 프록시를 Unwrap 검색하고, 프록시를 사용하여 원격 개체에 액세스하는 방법을 보여 줍니다.

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

// Unwraps the proxy to the MyType object created in the other AppDomain.
MyType^ testObj = dynamic_cast<MyType^>(obj->Unwrap());
if ( RemotingServices::IsTransparentProxy( testObj ) )
   Console::WriteLine( "The unwrapped object is a proxy." );
else
   Console::WriteLine( "The unwrapped object is not a proxy!" );

Console::WriteLine( "" );
Console::Write( "Calling a method on the object located in an AppDomain with the hash code " );
Console::WriteLine( testObj->GetAppDomainHashCode() );
// 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();

if(RemotingServices.IsTransparentProxy(testObj))
   Console.WriteLine("The unwrapped object is a proxy.");
else
   Console.WriteLine("The unwrapped object is not a proxy!");

Console.WriteLine("");
Console.Write("Calling a method on the object located in an AppDomain with the hash code ");
Console.WriteLine(testObj.GetAppDomainHashCode());
' Creates an instance of MyType defined in the assembly called ObjectHandleAssembly.
Dim obj As ObjectHandle = domain.CreateInstance("ObjectHandleAssembly", "MyType")

' Unwrapps the proxy to the MyType object created in the other AppDomain.
Dim testObj As MyType = CType(obj.Unwrap(), MyType)

If RemotingServices.IsTransparentProxy(testObj) Then
   Console.WriteLine("The unwrapped object is a proxy.")
Else
   Console.WriteLine("The unwrapped object is not a proxy!")
End If 
Console.WriteLine("")
Console.Write("Calling a method on the object located in an AppDomain with the hash code ")
Console.WriteLine(testObj.GetAppDomainHashCode())

호출자 참고

A ObjectHandle 는 원격 수명 서비스에 의해 추적되는 원격 MarshalByRefObject 입니다. 수명 임대가 만료되면 현재 메서드에 대한 호출이 ObjectHandle 실패할 수 있습니다.

적용 대상