xUnit and TD.Net: Fixing the “attempt was made to load an assembly from a network location” problem

I just started my first personal project using Visual Studio 2010, and being the conscientious TDD’er that I am, the first thing I did was set up xUnit.net and TestDriven.Net so that I could write my first, failing test. Instead of my expected test failure, I was greeted by this unfriendly error:

=== ERROR IN TEST RUNNER: xUnit.net 1.5 build 1479 ===
System.IO.FileLoadException: Could not load file or assembly 'file:///D:\Dev\DiceRoller\3rdParty\xUnit.net\xunit.runner.tdnet.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///D:\Dev\DiceRoller\3rdParty\xUnit.net\xunit.runner.tdnet.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.

I’m sure I could have fired up Google or poked around for a bit to solve this problem, but why bother when I have one of the xUnit creators right down the hall? Brad ran through the obligatory “you’re an idiot” checks (all of the files are there, the versions are right, etc.), and then showed me that I need to unblock the xunit.runner.tdnet.dll file, because it was copied from a network location:




After I clicked the Unblock button, I was able to run my test and I got the failure that I expected. I post this hoping it will help those less fortunate than me, who don’t have a xUnit creator close at hand. Happy TDD’ing!

Comments (16)
  1. Just wanted to let you know this post was a big help!  I had the problem with NUnit after migrating some projects to VS 2010 and updating to the latest NUnit.  After stumbling around, found your post and was able to get it working again.  Thank you!

  2. Andrew Gunn says:

    You are a proper Leg-End! Thaaanks.

  3. Skywalker says:

    I had this issue with a downloaded zipped Visual Studio project. After extracting the project and then opening it in Visual Studio, it gave the same error at compile time!

    Thanks to you I found out about the Unblock button (I unblocked the downloaded zip file and then everything works fine).

    A Big Thank you!!

  4. Michael Narinsky says:

    Your post just helped me a lot! Thank you!

  5. Kent Hansen says:

    Helped me as well. Thanks so much.

    I had to close the solution and relaunch VS for it to work for me.

  6. ZManPhilly says:

    Thanks, this surely saved me a lot of time!

  7. TeatimeTom says:

    Actually had the same problem using MonoDevelop. Never would have found what to do if not for this!

  8. Fred says:

    Thanks a lot.. helped a lot, saved me loads of headache.

  9. Loylick says:

    The whole day was lost until I found this topic. Thank you so much!  Microsoft writes misleading error messages. It's stupid to write "attempt was made to load an assembly from a network location” when obviously one runs a program from a local disk!  Why didn't they write something like: “attempt was made to load an assembly GOT from a network location. Try to unlock the assembly.”

  10. John Smith says:

    Thanks a lot! This helped me so much, greatly appreciate this 🙂

  11. Michael says:

    Helped me out greatly, appreciate it!

  12. Erik says:

    At last, after searching for the answer for at least an hour, I found it here. The Holy Grail!

  13. Kevin says:

    Thank you very much, really useful tip!!

  14. Uri Goldstein says:

    Thank you for posting this. It's 2015 and this little tip is still helping people out when stumbling upon this cryptic error message 🙂

  15. Tim says:

    Awesome! Thanks very much for posting this! Lost a few hours troubleshooting until I decided to google this error message and discovered this post.

  16. Ryan says:

    You literally saved my life today. I would've never thought to check if the .dll files were being blocked. It fixed my errors!

Comments are closed.

Skip to main content