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

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.


Related Articles


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 »

Here's how you can add "nofollow" tags to links generated by a Sitemap file that is bound to an ASP.NET Repeater control using a SiteMapDataSource. I'm currently using this technique for the footer links of GotKnowHow.com, so if you View Source of the...  more »

After setting up a new Windows 7 computer with IIS 7.5 and Visual Studio 2010, I tried to start my ASP.NET 4.0 website using the Local IIS web server. However, right off the bat I was hit with the following IIS error message: HTTP Error 500.21 - Internal...  more »

A regular expression for validating a image url.  more »

This is one of those simple web page design things that can drive a web developer absolutely crazy.  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 »

I recently moved my sites over to a new web server that has "Windows Server 2008 R2" installed. The older server had just been running "Windows Server 2008". After moving my sites over I discovered that my AJAX Toolkit AutoComplete functionality had...  more »