首页 新闻 会员 周边

创建应用程序域出错

0
悬赏园豆:20 [待解决问题]

我写了个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());
}

RyanZhu的主页 RyanZhu | 初学一级 | 园豆:155
提问于:2011-04-11 11:42
< >
分享
所有回答(1)
0

别把dll直接放到bin里.因为你没有做签名.

这样,你在你项目里添加引用,找到你的Intelligencer.cs所在的项目.

添加进去,每次你build网站的时候自动从项目引用就可以了.

DYStudio.Net | 园豆:1747 (小虾三级) | 2011-04-11 15:01
我添加了,本来Intelligencer.cs文件在另一个项目WebAppDomain中,我通过add reference添加进来,然后就可以使用这个类,然后直接创建这个类的对象是可以用的。但是现在我要建一个新的应用程序域,
Intelligencer intelligencer = System.Web.Hosting.ApplicationHost.CreateApplicationHost(hostType, "/", System.Environment.CurrentDirectory) as Intelligencer;
执行这段代码就报错了。还是一样的错误,找不到。我查书上说,创建应用程序域,要把文件编译成.dll放进gac或者bin中的。。我想直接从bin中找不到,那你说那个签名要怎么做呢?
支持(0) 反对(0) RyanZhu | 园豆:155 (初学一级) | 2011-04-11 16:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册