如何安装配置时,我使用命令行来构建C#/。NET?

人气:1,038 发布:2022-09-10 标签: configuration .net c# exception-handling

问题描述

在我的程序试图访问该DLL的网络驱动器,我得到这个错误信息。

When my program tries to access the dll in the network drive, I got this error message.

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.

继链接,我得到这个信息,我需要有这个配置。

Following the link, I got this info I need to have this configuration.

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

我如何把这个配置信息是什么? 我使用Visual Studio 2010,但我不使用Visual Studio IDE,只是有一个简单的批处理文件来生成C#code。

How do I put this configuration info to what? I use Visual Studio 2010, but I don't use Visual Studio IDE, but just have one simple batch file to build the C# code.

我发现这个网站使用App.config中,我认为这是不可能的使用方法,命令行构建。

I found this site using App.config, and I think it may not be possible to use method with command line build.

推荐答案

鉴于你的输出文件是foo.exe的。创建foo.exe.config,复制权foo.exe的旁边,并把这个在它:

Given your output file is foo.exe. Create foo.exe.config, copy it right next to foo.exe and put this in it:

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

460