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?


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


Found two items related to this one is saying to checking if your file is blocked (with some changed to your app.config) and another with changes to your project file. Hope this helps.

Link1

Link2


I found the solution to this problem following the accepted answer in this post:

Use FuseLogVw to keep track of where your program is breaking and how it is breaking. This application has a table with lots of traces. Find out where the fault application is called and see what is wrong with it.


That occurred to me when I was debugging the remote code in release mode; changed it to debug mode and got it fixed.