68

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?

3
  • Did you download Redmine.Net.Api dll from the web? Feb 13, 2014 at 12:17
  • @AishvaryaKarthik, yes, I did
    – svz
    Feb 13, 2014 at 12:23
  • 7
    Then right click on it and choose 'Unblock'. It might have been unblocked for some reasons. Feb 13, 2014 at 12:24

5 Answers 5

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

6
  • 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, 2014 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, 2014 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[_] Oct 28, 2014 at 16:10
  • 1
    This saved me alot of time... Thank you. I was having a similar issue with Newtonsoft.JSON
    – littlevahn
    Sep 25, 2015 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 7, 2017 at 15:05
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

1
  • 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, 2014 at 4: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.

1

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

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.