"Could not load file or assembly 'XXX.YYY' or one of its dependencies. The system cannot find the file specified."
I have a .net visual studio solution with a number of projects (class libraries and a web application).
I did some refractoring which moved files between projects, created new projects, deleted ones not being used and renamed some existing projects.
The solution builds without an issue but when I run the web application, the following exception occurs:
"Could not load file or assembly 'XXX.YYY' or one of its dependencies. The system cannot find the file specified."
The project called XXX.YYY which was deleted in the refractoring outputed a dll called XXX.YYY. But this isnt used anywhere in the application. I deleted the web applications obj directory and bin folder and rebuild but it still occurs.
Anyone have any ideas when this might be occurring, any tips??
UPDATE:
Update on my issue. I took the code place to another computer and ran it from there and it built and ran successfully without this issue occurring. So this makes me think the issue is with my PC rather than the code base. Maybe there is something cached on my PC. I did delete my temp files at "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" but no luck.
So anything else that could be cached or any other reason for it to occur on my PC.
FURTHER UPDATE
Another update on this. I have ran the same code on other developers machine and he doesnt have an issue running it. So must definitely be something on my machine! The only different on our machine is that I am running IIS7 with the app's app pool in classic mode. The other developer is running IIS6.
2 new pieces on information. Firstly in my httpmodules in my web.config, I have to remove a custom http module, before adding it. The other developer does not have to do this. Secondly, I have been able to fix the "Could not load file or assembly 'XXX.YYY' or one of its dependencies" issue via a "hack" which is only a short term fix by creat开发者_Python百科ing a class library in my project called XXX.YYY and including the classes being looked for, which are all custom controls ie. inheriting from System.Web.UI.WebControls.WebControl.
Any further thoughts....
There are two possible reasons.
1) When you run your webapp, you still use the old assemblies somewhere on your machines. Your old assemblies were referencing the old assembly "XXX.YYY".
2) The latest binary you built is still referencing the old assembly "XXX.YYY".
To find out what assemblies your webapp using, if you are running a debugger, you can easily find it out from the output windows. It should be first few lines of the output. Another way to find out is to open the Module windows in VS.NET IDE during debugging.
If you cannot debug it for some reasons or you have problems to attach a debugger, another easier way to do is to use fuslogvw. It gives you the exact locations of all successfully loaded assemblis as well as the assemblies that it failed to load. Please make sure you run the fuslogvw as Administrator in Windows 7.
After you find out what assemblies your webapp successfully loaded, you can do ildasm on those assemblies to see what assemblies they are referencing. You need to check them one by one unfortunately.
My guess is that some of your successfully loaded assemblies are actually coming from somewhere in the ASP.NET cache or GAC.
Enable Diagnostic logging for the build output (TOols -> Options -> Build And Run -> Output Log verbosity -> Diagnostic) and Build the solution and see from where Visual Studio picks the dll (somedll.dll version xxx.yy). Now run the Application and see where the runtime is trying to resolve the dll. (Windbg is an option).
just check the projects build configuration.. if there is an 64 bit compiled dll on your references and your main project is 32 bit (or any cpu and your machine is 32 bit) or vice versa you wil get this error
Do solution search for the text "XXX.YYY" and delete all occurences. Maybe you have sth left out in some web.config file.
Additionally you can check the *.csproj files if solution search finds nothing. They're basically text files, so there should be no problem removing references.
Use the Dependency Walker (depends) on all of your EXEs and DLLs to see which one has the dependency that is missing. You should run depends from the working directory of your project for best results.
Once you know which EXE/DLL is the culprit, go into the settings for that project and see if the complained about dependency is mentioned there.
EDIT: Another thing occurred to me a few minutes ago... If any of your dependencies are "blocked" because they were marked as downloaded by some MS tardware (When you DL with Inet explorer for example) that can prevent executable code from loading. Look at the properties of your executables (DLL/EXE) with Windows Explorer and see if they have an unblock button on the first page. If so, click that button. This took me some time to figure out a while back, hopefully it'll help.
You are simply missing a dependency. Its probably a situation like Project A has a reference to Project B which has a reference to Project C. Your output directory is missing the DLL for Project C.
Great news I have solved the issue!!! I had to reinstall my .net runtime environment. I also deleted sites from IIS and readded the website again. When I ran it, the issue did not occur and site ran.
A big thank you to everyone for their help and assistance, very much appreciated. All the advice and help steered me in the direction to solve this!
Go to References
in Solution Explorer
in Visual Studio
. Select the assembly which is getting complained. Select it and go to View
menu option and select Property Window
at the bottom. While the assembly is selected, view its properties in the property windows and look for Copy Local
value. If its value is set to False
, set it to True
. Build the solution and publish it. It should successfully solve the problem.
精彩评论