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


There's a good chance that if you're database driven application is running into the following sql error message that says "String or binary data would be truncated", that the error is being caused by an issue in a SQL statement or in the SQL code of a...  more »

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 one quick fix for the ASP.NET error System.FormatException: Input string was not in a correct format. when you are using a DataList with an asp:Button control and are trying to get the CommandArgument using the DataList_RowCommand. Keep in mind...  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 »

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 »

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 »

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 »