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.
User contributions licensed under CC BY-SA 3.0