67

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?

svz
  • 4,516
  • 11
  • 40
  • 66

5 Answers5

205

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

MusicLovingIndianGirl
  • 5,909
  • 9
  • 34
  • 65
  • 5
    In my case I also had to remove the "Read Only" attribute from the file. Only then the Unblock button really worked for me. – Ekus Apr 15 '14 at 16:37
  • 1
    had the same kind of problem, application blocked the assembly and came up with this vage error. Thank you very much :) – Mario Jul 14 '14 at 18:09
  • 2
    It might help to say that you need to right-click the file in the Windows Explorer, not Visual Studio. c[_] – Mario Tacke Oct 28 '14 at 16:10
  • 1
    This saved me alot of time... Thank you. I was having a similar issue with Newtonsoft.JSON – littlevahn Sep 25 '15 at 21:24
  • 1
    I was getting this same error loading an assembly in PowerShell. I was able to use the `Unblock-File` cmdlet to unblock all the assemblies I needed. Note that I had to restart PowerShell before it would let me `Add-Type` the assemblies! – Bacon Bits Jul 07 '17 at 15:05
  • Always forget what it was. A better exception would be appreciated. I guess it's OS level but still ... – Pavel Donchev Oct 02 '17 at 18:46
3

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

Community
  • 1
  • 1
Miguel
  • 1,157
  • 1
  • 15
  • 28
  • 2
    Thanks for your answer! The first link here does provide the required soultion. I accepted @Aishvarya's answer because it was given earlier as a comment. – svz Feb 14 '14 at 04:47
1

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.

Community
  • 1
  • 1
Reudismam
  • 97
  • 4
1

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

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Avinash
  • 305
  • 6
  • 14
0

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>
Matt
  • 688
  • 5
  • 12