I received an executable which uses .NET to load a dll and perform some database migration tasks. When I tried to run it, I was greeted with the following error:

!!! System.IO.FileLoadException: Could not load file or assembly 'file:///C:\PATH\REDACTED.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\PATH\REDACTED.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. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

I tried to follow the link in the error message but it was not clear to me where I would set <loadFromRemoteSources>.

Is it a .NET version mismatch thing?


Looks like the error was caused by the dll being blocked by the OS. I fixed the issue by navigating to the dll, going to its properties, and clicking the unblock button.

Hat tip to https://mathematica.stackexchange.com/questions/54779/a-net-exception-occurred-system-io-fileloadexceptioncould-not-load-file-or-as

  • 1
    Was just going to suggest that! Congrats on finding the solution so quickly :) – Signal15 Jan 7 '15 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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