Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio "Could not load file or assembly. Operation is not supported" error in Release mode

I have a small project in C# that uses two external dll files. One is the Redmine.Net.Api.dll and the other is NLog.dll. I'm using Visual Studio 2010. I added both files as Reference to my project. The problem is that when I run the project in Debug mode, it compiles, but when I switch to Release, it says:

Error 1 Could not load file or assembly 'file:///C:\project\lib\Redmine.Net.Api.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\project\SGEN project

How can I fix this?

like image 978
svz Avatar asked Feb 13 '14 12:02

svz


People also ask

How do you fix Could not load file or assembly or one of its dependencies?

There are some workarounds for this issue: The dll file may not be in /bin folder. Just copy the dll file to /bin folder or set this preference Copy Local = True from Visual Studio. If the problem persists, check if the version of the assembly that is referenced is different than the version it is looking for.

Could not load file or assembly assembly load?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.


1 Answers

Did you download Redmine.Net.Api dll from the web? If yes, then browse to it with Windows Explorer, right click on it and choose properties. There you should click 'Unblock'. It might have been blocked for some reasons.

enter image description here

like image 164
MusicLovingIndianGirl Avatar answered Sep 22 '22 14:09

MusicLovingIndianGirl