I was having this strange problem last week, and thought that I would share my experience about it with the developer community at large.
I had this project in Visual Studio (VS) 2005, that had two class library components and 1 Web service. One of the class libraries needed to reference a COM DLL. As such, when it is referenced within the Web Service it is copied into it's Bin folder. All fine an fair enough.
However, when I was compiling the Web Service I kept getting this strange error (X is the name of the COM DLL) :
Could not load file or assembly 'X' or one of its dependencies. Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'X' or one of its dependencies. Access is denied.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Assembly Load Trace: The following information can be helpful to determine why the assembly 'X' could not be loaded.
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].
|
I tried lots of different things to try and get it resolved. Such as deleting the COM DLL that it was referring to, re-compiling, including the DLL directly. Nothing ever worked, or simply threw me a different error for a bit, but after resolving that it went back to the original error!
Eventually, after lots of hair pulling, news group searching, blog reading, etc. I found my answer. There isn't actually anything wrong with the COM DLL or the projects as such. In my web.config file, I was using:
<identity impersonate="true" userName="domain\username" password="password" />
I found that this was causing the problem, as the user I was impersonating either did not exist or simply did not have the correct privileges to use the COM DLL, or even create temporary ASP.NET files!
So, all I did was use correct username and password details, and it solved my problem!