C#如何配置应用程序域

转载:http://www.csharpwin.com/csharpspace/9175r9023.shtml

您可以使用 AppDomainSetup 类,为新应用程序域提供带有配置信息的公共语言运行库。创建自己的应用程序域时,最重要的属性是 ApplicationBase。其他 AppDomainSetup 属性主要由运行时宿主用于配置特殊的应用程序域。

ApplicationBase 属性定义应用程序的根目录,当运行时需要满足类型请求时,它在 ApplicationBase 属性指定的目录中探测包含该类型的程序集。

注意

新的应用程序域只继承创建者的 ApplicationBase 属性。

下面的示例创建 AppDomainSetup 类的实例,此类用于创建新的应用程序域,将信息写入控制台,然后卸载应用程序域。

   1:  using System;
   2:  using System.Reflection;
   3:  class AppDomain4
   4:  {
   5:      public static void Main()
   6:      {
   7:          // Create application domain setup information.
   8:          AppDomainSetup domaininfo = new AppDomainSetup();
   9:          domaininfo.ApplicationBase = "F:\\work";
  10:   
  11:          // Create the application domain.
  12:          AppDomain domain = AppDomain.CreateDomain("MyDomain", null, domaininfo);
  13:   
  14:          // Write application domain information to the console.
  15:          Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
  16:          Console.WriteLine("child domain: " + domain.FriendlyName);
  17:          Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase);
  18:   
  19:          // Unload the application domain.
  20:          AppDomain.Unload(domain);
  21:          Console.ReadLine();
  22:      }
  23:  }

转载于:https://www.cnblogs.com/zhaox583132460/p/3444982.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值