//activator 应用
public void ActivatoTest()
{
object o = System.Activator.CreateInstance(typeof(StringBuilder));//创建指定对象 StringBuilder sb = o as StringBuilder;
sb.Append("dd"); System.Runtime.Remoting.ObjectHandle ob =
new System.Runtime.Remoting.ObjectHandle(
Activator.CreateInstanceFrom(System.Reflection.Assembly.GetEntryAssembly().CodeBase,//获取默认应用程序域进程可执行文件最初指定位置
typeof(Test).FullName));//在指定应用程序域中创建指定类型的实例
Test t = ob.Unwrap() as Test;//返回被包装的对象
t.method1(); }
//将程序集加载到应用程序域中
public void AppDomains()
{
System.AppDomainSetup ads = new AppDomainSetup();//应用程序域设置
ads.ApplicationBase = @"f:\work\development\test\";
System.AppDomain domain = System.AppDomain.CreateDomain("domain", null, ads);//加载应用程序域
Console.WriteLine(System.AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine(domain.SetupInformation.ApplicationBase); System.AppDomain.Unload(domain);//卸载应用程序域 }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货