当我使用命令行构建C#/ .NET时,如何设置配置?
当我的程序尝试访问网络驱动器中的dll时,我收到了此错误消息。
Unhandled Exception:
System.IO.FileLoadException: Could not load file or assembly 'file:///Z:smchoworkstasks2011ning_fpgabackendmyclass.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.
在链接之后,我得到了这个信息,我需要这个配置。
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
我如何把这个配置信息放到什么地方? 我使用Visual Studio 2010,但是我没有使用Visual Studio IDE,但只是有一个简单的批处理文件来构建C#代码。
添加
我发现这个网站使用App.config,我认为可能无法使用命令行构建方法。
鉴于你的输出文件是foo.exe。 创建foo.exe.config,将其复制到foo.exe旁边并放入它:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
你有没有尝试过AllowPartiallyTrustedCallers
?
上一篇: How do I setup configuration when I use command line to build C#/.NET?
下一篇: NetBeans 7.0 , JUnit and Glassfish Embedded 3.1: Does not work