pro*_*eek 7 .net c# configuration exception-handling
当我的程序试图访问网络驱动器中的DLL时,我收到此错误消息.
Unhandled Exception:
System.IO.FileLoadException: Could not load file or assembly 'file:///Z:\smcho\works\tasks\2011\ni\ng_fpgabackend\myclass.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
---> 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 maybe 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.
Run Code Online (Sandbox Code Playgroud)
在链接之后,我得到了这个信息,我需要这个配置.
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
如何将此配置信息置于什么位置?我使用Visual Studio 2010,但我没有使用Visual Studio IDE,只是有一个简单的批处理文件来构建C#代码.
我发现这个站点使用App.config,我认为可能无法使用命令行构建方法.
假设您的输出文件是 foo.exe。创建 foo.exe.config,将其复制到 foo.exe 旁边并将其放入其中:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)