ObjectHandle.Unwrap メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim instance As ObjectHandle Dim returnValue As Object returnValue = instance.Unwrap
ラップされたオブジェクト。
別の AppDomain 内のオブジェクトをアクティブにし、Unwrap メソッドを使用してこのオブジェクトへのプロキシを取得して、このプロキシを使用してリモート オブジェクトにアクセスする方法を、次のコード例に示します。
' 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())
// 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. 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() );
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- ObjectHandle.Unwrap メソッドのページへのリンク