Csharp/C Sharp by API/System.Runtime.Remoting/ObjectHandle

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

ObjectHandle.Unwrap

using System;
using System.Runtime.Remoting;
using System.Reflection;
class MainClass
{
  public static void Main() 
  {
    AppDomain d = AppDomain.CreateDomain("NewDomain");
    
    ObjectHandle hobj = d.CreateInstance("AnotherDomain", "SimpleObject");
    SimpleObject so = (SimpleObject) hobj.Unwrap();
    Console.WriteLine(so.Display("make this uppercase"));
    AppDomain.Unload(d);
    Console.WriteLine(so.Display("make this uppercase"));
  }
}

[Serializable]
public class SimpleObject 
{
  public String Display(String inString)
  {
    return(inString.ToUpper());
  }
}