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


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:
  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:




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:  

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.

Related Posts

After running a ASP.NET website on IIS 7.5 for the first time on a Windows 7 computer, I was faced with the following error message: Login failed for user 'IIS APPPOOL\ASP.NET v4.0'. Description: An unhandled exception occurred during the execution of the...  more »

Here's how you can UrlEncode the plus sign (+) in a URL querystring in ASP.NET and then retrieve the plus symbol after UrlDecoding the string. In this example, I will do a postback and redirect the Server.UrlEncoded string to another page. First we will...  more »

For a while I wasn't sure how to access GetRouteUrl from an .ashx IHttpHandler page. I wanted to access route url's setup in the Global.asax file to be used in files like rss.ashx, instead of having to hard codes the page URL's in my .ashx pages. Well,...  more »

Adding a CSS border to an ASP.NET Image control was a mystery to me for the longest time. While you could easily use an html image and add the runat="server" to it and then add CSS, I really wanted to use an asp:Image control along with a CSS border....  more »

SQL Server Reporting Services can be a pain in the arse to set up correctly for the first time. Even after you've got things running correctly, you can sometimes run into issues, which is exactly what happened to me recently. I had setup my local...  more »

So yesterday, I started getting green squiggly line validation warnings at design time on ASP.NET server controls within the HTML Design view for my Visual Web Developer 2010 Express project in Windows 7. Essentially, intellisense on all the ASP.NET...  more »

A regular expression for validating a image url.  more »

The AjaxFileUpload control that's part of the AJAX Control Toolkit, works great for easily uploading multiple files at once. However, it gets a little tricky if you want to update an UpdatePanel after all the files have finished uploading, especially if...  more »