04-应用程序域
来源:互联网 发布:湖南网络系统集成商 编辑:程序博客网 时间:2024/06/13 02:02
using System.Web.Hosting;
namespace _04_应用程序域
{
public class Intelligencer : System.MarshalByRefObject
{
public string Report()
{
System.AppDomain appdomain = System.AppDomain.CurrentDomain;
StringBuilder builder = new StringBuilder();
// 应用程序域的信息
builder.AppendFormat("Domain ID: {0}\r\n", appdomain.Id);
// 对于每一个 Web 应用程序域,有一个 HostingEnvironment
builder.AppendFormat("VirtualPath: {0}\r\n",
HostingEnvironment.ApplicationVirtualPath);
builder.AppendFormat("PhysicalPath: {0}\r\n",
HostingEnvironment.ApplicationPhysicalPath);
return builder.ToString();
}
}
}
//调用该类
using System;
namespace _04_应用程序域
{
class Program
{
static void Main(string[] args)
{
System.Type hostType = typeof(Intelligencer);
Intelligencer intelligencer
= System.Web.Hosting.ApplicationHost.CreateApplicationHost(
hostType,
"/",
System.Environment.CurrentDirectory
)
as Intelligencer;
Console.WriteLine("Current Domain ID: {0}\r\n", AppDomain.CurrentDomain.Id);
Console.WriteLine(intelligencer.Report());
Console.Read();
}
}
}
特别注意:
这个方法需要创建一个新的应用程序域,这个应用程序域将重新加载hostType,方法将按照以下顺序来寻找定义hostTYpe类型的程序集:
1)GAC
2)网站物理文件目录下的bin文件夹
- 04-应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序域
- 应用程序池(应用程序域)
- 应用程序池与应用程序域
- 创建多线程应用程序和应用程序域
- 04-bat启动应用程序关闭应用程序
- 线程 应用程序域 进程
- Guava学习之HashBiMap
- C语言实现大数整数乘法
- 数字万用表测量二极管、三极管
- 茴香防治口臭?美国公布9个神奇的健康偏方
- 11.网络编程之四
- 04-应用程序域
- S3C2410 实验十—— SPI(串口外设接口)实验
- DataGuard环境搭建
- 外观模式解析
- Chrome DevTools
- C++ 中 关于指针内存
- 12.网络编程之五
- Android 匿名共享内存C++接口分析
- Ubuntu 12.04上搭建Hadoop环境(一)