我收到一个可执行文件,它使用.NET来加载一个DLL并执行一些数据库迁移任务。 当我试图运行它,我遇到了以下错误:
!!! 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) ...
我试图按照错误消息中的链接,但是我不清楚在哪里设置<loadFromRemoteSources>。
这是一个.NET版本不匹配的东西?
看起来像错误是由操作系统被阻止的DLL造成的。 我通过导航到dll,去它的属性,然后点击取消阻止button来解决这个问题。