我写了个Intelligencer.cs类文件,然后编译成了.dll,分别放到了website和applicaion下的bin文件夹中,然后using之,用过CreateApplicationHost创建新的应用程序域,但是,它帮我报错Could not load file or assembly 'Intelligencer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.求高手指导~~
public class Intelligencer:MarshalByRefObject
{
public string Report()
{
AppDomain appDomain = AppDomain.CurrentDomain;
StringBuilder builder = new StringBuilder();
builder.AppendFormat("Domain ID :{0}\r\n", appDomain.Id);
builder.AppendFormat("VirtualPath :{0}\r\n", HostingEnvironment.ApplicationVirtualPath);
builder.AppendFormat("PhysicalPath{0}:\r\n", HostingEnvironment.ApplicationPhysicalPath);
return builder.ToString();
}
}
protected void Page_Load(object sender, EventArgs e)
{
System.Type hostType = typeof(Intelligencer);
Intelligencer intelligencer = System.Web.Hosting.ApplicationHost.CreateApplicationHost(hostType, "/", System.Environment.CurrentDirectory) as Intelligencer;
Response.Write(AppDomain.CurrentDomain.Id);
Console.WriteLine(intelligencer.Report());
}
别把dll直接放到bin里.因为你没有做签名.
这样,你在你项目里添加引用,找到你的Intelligencer.cs所在的项目.
添加进去,每次你build网站的时候自动从项目引用就可以了.