从 Windows Server 2008 上的可执行文件加载 dll 时出错

从 Windows Server 2008 上的可执行文件加载 dll 时出错

我收到了一个可执行文件,它使用 .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 版本不匹配的问题吗?

答案1

错误似乎是由操作系统阻止 dll 引起的。我通过导航到 dll、转到其属性并单击解除阻止按钮解决了该问题。

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

相关内容