How to Fix - Could not load file or assembly 'Elmah' or one of its dependencies
by
Doug
Updated July 17, 2010
Unblock Elmah compressed folder in Windows Vista.
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):
- Re-download the Elmah zip file: http://code.google.com/p/elmah/downloads/detail?name=ELMAH-1.1-bin.zip
- Then right-click on the ELMAH-1.1-bin zipped folder, and select Properties.
- 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.
- Then click OK.
- Now right-click again on the compressed ELMAH-1.1-bin zipped folder and select Extract All to unzip the folder.
- 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