问题
This has been bothering me for a while now:
Could not load file or assembly 'app_code' or one of its dependencies.
The system cannot find the file specified.
I'm using visual studio 2008 and IIS6 and for some reason I get this weird error.
Why is it trying to load 'app_code', and why does it fail?
Tried to resolve it/ find out more using the information in the exception
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].
But that didn't help, neither did the information in the msdn article about the Assembly Binding Log Viewer: (http://msdn.microsoft.com/en-us/library/e74a18c4.aspx)
Anyone can shine a light on this abomination? I'm guessing this is a newbie mistake but I have no idea where to look now. Could it be IIS 6.0 configuration issue? I am using Windows XP Professional Edition and Visual Studio 2008.
After getting the Assembly binding monitor up, it spews out something like:
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.
回答1:
If you use Visual Studio Performance Tools then it is possible that Visual Studio left a key in your web.config appsettings section. It causes a 32 bit library to load, which won't work if your application is loading in 64 bit mode.
Check for the following and remove it:
<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsinstr.exe"/>
回答2:
This is just a stab in the dark, but maybe there's a problem with your ASP.Net installation on your IIS. Try opening a Visual Studio command prompt and running
aspnet_regiis -i
This will reinstall ASP.Net into IIS.
回答3:
This error was due to web.config was referencing the wrong package for a class. Clearing the mind over the weekend, and problems are solved easily.
回答4:
This error happened to me when I first tried to deploy a recently upgraded app (vs2008 to vs2010) using the "Publish..." option and didnt asked to delete the original content.
回答5:
I got this error when I try to make a publish.
Try to disable your antivirus.
This work for me!
来源:https://stackoverflow.com/questions/1246853/could-not-load-file-or-assembly-app-code-or-one-of-its-dependencies