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

C#Visual Studio-2010

C# Problem Overview


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?

C# Solutions


Solution 1 - C#

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

Solution 2 - C#

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

Solution 3 - C#

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.

Solution 4 - C#

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

Solution 5 - C#

Add <loadFromRemoteSources enabled="true" /> to your app.config file as shown below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
	    <loadFromRemoteSources enabled="true" />
    </runtime>
    ...
</configuration>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsvzView Question on Stackoverflow
Solution 1 - C#MusicLovingIndianGirlView Answer on Stackoverflow
Solution 2 - C#MiguelView Answer on Stackoverflow
Solution 3 - C#ReudismamView Answer on Stackoverflow
Solution 4 - C#AvinashView Answer on Stackoverflow
Solution 5 - C#MattView Answer on Stackoverflow