不允许从网络位置加载程序集

问题描述:

我最近建立了一个新的 Windows Server 2012 R2 环境并安装了 Visual Studio 2012

I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012.

现在我有多个 .NET 4.5 项目,我是从旧服务器Windows Server 2008计算机迁移过来的。

Now I'm having a problem with multiple .NET 4.5 project's I migrated from my old server, a Windows Server 2008 machine. This never occurred on the old server.

当尝试从网络位置加载程序集时,遇到了以下问题:

When trying to load an assembly from a network location, I run into the following issue:


试图从网络位置加载程序集,这可能导致该程序集在.NET Framework的早期版本中被沙箱化。默认情况下,此版本的.NET Framework不启用CAS策略,因此此加载可能很危险。如果此负载不是要对程序集进行沙箱处理,请启用loadFromRemoteSources开关。请参阅 http://go.microsoft.com/fwlink/?LinkId=155569 更多信息。

看过 其他 问题 ,但没有一个提供有效的解决方案。

I've looked at some other questions, but none of them provide a working solution.

这是我到目前为止尝试过的:

This is what I've tried so far:


  • loadFromRemoteSources 开关添加到 devenv.config , XDesProc.exe.appx.config XDesProc.exe.config

  • 已选中程序集是否为 ,它不是从网络位置制成的组件,而是从网络位置-problem.aspx rel = noreferrer>阻止的。

  • 已尝试使用 CasPol 实用程序,即使它仅适用于.NET 4.0之前的项目。

  • Added the loadFromRemoteSources switch to devenv.config, XDesProc.exe.appx.config and XDesProc.exe.config.
  • Checked whether the assembly was blocked, which it wasn't.
  • Tried using the CasPol utility, even though this only applies to pre .NET 4.0 projects.

所有操作均未成功。

是否有另一种解决方案来解决此问题?

Is there another solution to solve this problem?

添加 loadFromRemoteSources 切换 machine.config 解决了该问题。

Adding the loadFromRemoteSources switch to machine.config solved the problem.

MSDN


loadFromRemoteSources 元素指定是否应使用远程源中的程序集被授予完全信任。

The loadFromRemoteSources element specifies whether assemblies from remote sources should be granted full trust.

示例

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

您可以找到 machine.config 此处

32位

%windir%\Microsoft.NET\Framework\[version]\config\machine.config

64位

%windir%\Microsoft.NET\Framework64\[version]\config\machine.config