无法加载文件或程序集'app_code'或其依赖项

4
这个问题困扰我已经有一段时间了:
Could not load file or assembly 'app_code' or one of its dependencies. 
The system cannot find the file specified.

我正在使用Visual Studio 2008和IIS6,在某些情况下出现了奇怪的错误。

为什么它会尝试加载'app_code',为什么会失败?

尝试使用异常中的信息来解决/查找更多信息。

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

但这并没有帮助,MSDN文章中关于程序集绑定日志查看器的信息也没有用:(http://msdn.microsoft.com/en-us/library/e74a18c4.aspx)。
有人能解决这个问题吗?我猜这是新手错误,但我不知道该去哪里找答案。这可能是IIS 6.0配置问题吗?我的操作系统是Windows XP Professional Edition,使用的是Visual Studio 2008。
在获取程序集绑定监视器后,它会输出类似以下内容:
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\NNNNNN\src\Trunc\Web\web.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.Web, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d94fb3b9/d76068ec/Microsoft.VisualStudio.Web.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d94fb3b9/d76068ec/Microsoft.VisualStudio.Web/Microsoft.VisualStudio.Web.DLL.
LOG: Attempting download of new URL file:///C:/Projects/NNNNNN/src/Trunc/Web/bin/Microsoft.VisualStudio.Web.DLL.
LOG: Attempting download of new URL file:///C:/Projects/NNNNNN/src/Trunc/Web/bin/Microsoft.VisualStudio.Web/Microsoft.VisualStudio.Web.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d94fb3b9/d76068ec/Microsoft.VisualStudio.Web.EXE.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/d94fb3b9/d76068ec/Microsoft.VisualStudio.Web/Microsoft.VisualStudio.Web.EXE.
LOG: Attempting download of new URL file:///C:/Projects/NNNNNN/src/Trunc/Web/bin/Microsoft.VisualStudio.Web.EXE.
LOG: Attempting download of new URL file:///C:/Projects/NNNNNN/src/Trunc/Web/bin/Microsoft.VisualStudio.Web/Microsoft.VisualStudio.Web.EXE.
LOG: All probing URLs attempted and failed.

我忘了提到我们在使用单独的库来编写代码,而不是使用App_Code文件夹。在我的项目中,App_Code文件夹为空。 - Andreas
该解决方案还包括一个子站点,它是使用MVC构建的,因此它是混合了ASP.NET常规表单和ASP.NET MVC。 - Andreas
6个回答

3
如果您使用Visual Studio性能工具,则可能会在web.config的appsettings部分中留下一个键。 它会导致加载32位库,如果您的应用程序以64位模式加载,则无法正常工作。
请检查以下内容并将其删除:
<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsinstr.exe"/>

0

当我第一次尝试使用“发布...”选项部署最近升级的应用程序(从vs2008到vs2010)时,出现了这个错误,而我没有要求删除原始内容。


0

当我尝试发布时,出现了这个错误。

尝试禁用您的防病毒软件。

这对我有用!


0

这只是一次猜测,但也许你的IIS上的ASP.Net安装存在问题。尝试打开Visual Studio命令提示符并运行

aspnet_regiis -i

这将重新安装ASP.Net到IIS中。


1
谢谢您的回复。然而,我已经尝试过重新安装ASP.NET,但没有帮助。如果必须重新安装环境,那将会很糟糕,因为发现实际发生了什么将非常有趣。 - Andreas

0

我的应用程序的目标框架是.NetFramework 4。但我在IIS中选择了.NET版本v2作为应用程序池的.NET CLR版本。 我已将应用程序池的.NET CLR版本从v2更改为v4,并且对我有用。


-1

这个错误是由于web.config引用了错误的类包。周末放松一下,问题就很容易解决了。


3
您能否详细说明哪个汇编文件被错误引用了?我也遇到了同样的问题,需要您的帮助。 - Naveed Butt
1
为什么你没有告诉我们是哪个程序集被引用错误了!!我认为这不需要花费太多力气就可以解决! - Ibrahim Amer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接