【发布时间】:2011-04-12 02:12:46
【问题描述】:
在追求a spearate problem 的过程中,我遇到了一个非常奇特的情况。演示代码是:
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Log("In Application_Start");
SomeClass.SomeProp = ConfigurationManager.AppSettings["PropValue"];
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
Log("In Application_BeginRequest");
try
{
this.Application_Start(null, null);
}
catch ( Exception ex )
{
Log(ex.ToString());
}
Log("At the end of Application_BeginRequest");
}
}
我在日志中得到的是:
In Application_BeginRequest
Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException
at MyRootNamespace.Global.Application_Start(Object sender, EventArgs e)
at MyRootNamespace.Global.Application_BeginRequest(Object sender, EventArgs e) in D:\My Documents\Visual Studio 2008\Projects\SolutionDir\ProjectDir\Global.asax.cs:line 109
At the end of Application_BeginRequest
这对我来说毫无意义。考虑:
-
vjslib被我的主要项目(程序集)引用,其中包括Global类。如果无法解析其依赖关系,为什么还要加载程序集? -
SomeClass位于另一个程序集中,该程序集也引用了vjslib。SomeClass确实使用了vjslib并且一些成员确实公开了派生自vjslib中的类的类,但这里使用的属性只是一个普通的旧字符串。 - 为什么堆栈跟踪的第一行没有行号?
是否在每个方法的基础上解决了依赖关系?我以为Microsoft doesn't do such things anymore。这是怎么回事?
【问题讨论】:
标签: .net assemblies dependencies