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 Posts


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 »

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 below I'm going to share with you a fairly easy to use and understand ASP.NET User Control that allows you to pick a Date (with the ajaxToolkit CalenderExtender) and also select the Time of day using a drop down list. I've named the control...  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 »

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 »

If you do any sort of ASP.NET programming there usually comes a time when you need to get a websites Base URL. The following shows two examples, the first example shows how to get the Base Site Url using C#, which can be used for getting both the...  more »

The default settings in Visual Studio 2010 Professional do not automatically show the Solution file by default in the Solution Explorer sidebar. This can be a bit of a problem if you are trying to add another project to your existing solution. To get the...  more »