tags:

views:

34

answers:

2

Hi,

I am getting following error when I run an exe referencing a particular DLL.

Could not load file or assembly 'XYZ.ABC.DEF, Version=1.0.3801.24033, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.

Could the above error be due to XYZ.ABC.DEF.DLL being corrupt? What could be wrong with the DLL to cause this error. We just tried to use Reflector tool on this DLL and we could not reflect it.

Please help.

+2  A: 

The most likely cause for this happening is that either the assembly or one of it's dependencies has permissions that prevent the current process from accessing the file. If it were corrupted you would likely see a BadImageFormatException or the like error message. The access denied error is the result of a permission issue somewhere in the chain.

The next step is to simply try and open the DLL using the same credentials and see what occurs. Or use fuslogvw to track the load failure and figure out exactly which DLL is having the problem.

JaredPar
You can get the fusion log viewer documentation here: http://msdn.microsoft.com/en-us/library/e74a18c4(v=VS.90).aspx
Eric Lippert
I can not get Fuslogvw to list any Dll. I put my dll into c:\mydll folder. Under settings i mention custom log path as c:\mydll and choose Log all binds to disk and check the box for Enable Custom log path. But still no luck
dotnet-practitioner
The permissions were missing on this DLL. Once the permissions were restored, the DLL worked as expected. Could a blade logic package while building the DLL impact the permissions? How could the permissions be altered?
dotnet-practitioner
+1  A: 

"Access is denied" usually means that you don't have permissions to read a file. This could happen if the dll is in a protected system location (even if you are an administrator you can get "access denied" on files within a different user's account folders, for example)

Make sure you have admin privileges, and try copying the dll and its dependencies to a folder that you have full access permissions for.

Jason Williams