How to Fix - Could not load file or assembly 'Elmah' or one of its dependencies

May 15, 2010 By

I recently ran into the following error while trying to get Elmah to work / complie with my Web Application Project in Visual Studio 2010:

Could not load file or assembly 'file:///C:\Users\DOUGDELL2\Documents\Visual Studio 2010\Projects\MyWebsiteBuilderWAP\MyWebsiteBuilderWAP\bin\Elmah.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

This error was occuring when I referenced the Elmah.dll in my web application project.  However, the error was not occurring when I just had the Elman.dll in my bin folder, without referencing Elmah in the project (while this will work to get Elmah running, if you need to use the ErrorSignal class: ErrorSignal.FromCurrentContext().Raise(ex); you need to have Elmah directly referenced in the project.

So to allow the Elmah assembly to load when building a WAP project follow  these steps (on Windows Vista):

  1. Re-download the Elmah zip file: http://code.google.com/p/elmah/downloads/detail?name=ELMAH-1.1-bin.zip
  2. Then right-click on the ELMAH-1.1-bin zipped folder, and select Properties.
  3. In the General tab, go down to the Security section and next to "This file came from another computer and might be blocked to help protect this computer." and click the Unblock button.
  4. Then click OK.
  5. Now right-click again on the compressed ELMAH-1.1-bin zipped folder and select Extract All to unzip the folder.
  6. Re-add the Elmah.dll to you bin folder, and then Add a Reference to Elmah.

After adding the unblocked Elmah.dll file to your projects bin folder and then referencing it, you should now be able to build your Web Application Project and have it compile correctly.

Just as a reference, check out this same process when downloading and extracting the Ajax Control Toolkit as seen here: http://www.asp.net/ajaxlibrary/act.ashx

 


0
5

5 Comments

anonymous by Don Sabio on 8/5/2010
Thanks for the informative post. I was having the issue with the Ajax Control Toolkit and your instructions helped to remedy the issue.
Doug by Doug on 8/5/2010
Hey Don,

Glad it helped... Initially, I had run into the problem with the Ajax Control Toolkit as well. Then when it happened to me again with the Elmah.dll, I remembered back to what had caused the problem I had when using the AjaxControlToolkit.dll in my project... Both issues turned out to have the same solution.
anonymous by Allen on 9/8/2010
This solution actually works broadly against any referenced component to a .NET project that was originally downloaded as a .zip before extracting the binary. I did it to (2) problematic 3rd part .dlls that kept giving this error in VS.NET 2010 in a 'Release' build. It was never a problem with a debug build.
anonymous by Nicho on 12/16/2010
If you go to the bin folder with the problem dll, right click -> properties, in the properties window you will have the option to unblock.
Thanks Nicho, I've never tried it that way, but it definitely seems like that's an easier way to get around this dll problem.

Add your comment

by Anonymous - Already have an account? Login now!
Your Name:  

Comment:  
Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your comment will appear after being approved.