不允许从网络位置加载程序集 [英] Not allowed to load assembly from network location
问题描述
我最近设置了一个新的 Windows Server 2012 R2 环境并安装了 Visual Studio 2012.
现在我遇到了多个 .NET 4.5 项目的问题,我从旧服务器(一台 Windows Server 2008 机器)迁移而来.这在旧服务器上从未发生过.
尝试从网络位置加载程序集时,我遇到了以下问题:
<块引用>尝试从网络位置加载程序集,这会导致该程序集在 .NET Framework 的早期版本中被沙箱化.默认情况下,此版本的 .NET Framework 不启用 CAS 策略,因此这种加载可能很危险.如果此加载不打算对程序集进行沙箱处理,请启用 loadFromRemoteSources 开关.请参阅 http://go.microsoft.com/fwlink/?LinkId=155569 了解更多信息.
我看过at 一些 其他 问题,但没有一个提供有效的解决方案.
这是我迄今为止尝试过的:
- 将
loadFromRemoteSources
开关添加到 devenv.config、XDesProc.exe.appx.config 和 XDesProc.exe.config. - 检查程序集是否被阻止,但事实并非如此.莉>
- 尝试使用 CasPol 实用程序,即使这仅适用于 .NET 4.0 之前的项目.
一切都没有成功.
是否有其他解决方案可以解决此问题?
添加 loadFromRemoteSources
切换到machine.config 解决了这个问题.
MSDN
<块引用>loadFromRemoteSources
元素指定是否应授予来自远程源的程序集完全信任.
示例
<预><代码><配置><运行时><loadFromRemoteSources enabled="true"/></运行时></配置>您可以在 machine.config 此处找到::>
32 位
%windir%Microsoft.NETFramework[版本]configmachine.config
64 位
%windir%Microsoft.NETFramework64[版本]configmachine.config
I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012.
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:
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.
I've looked at some other questions, but none of them provide a working solution.
This is what I've tried so far:
- 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.
All without success.
Is there another solution to solve this problem?
Adding the loadFromRemoteSources
switch to machine.config solved the problem.
MSDN
The
loadFromRemoteSources
element specifies whether assemblies from remote sources should be granted full trust.
Example
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
You can find machine.config here:
32-bit
%windir%Microsoft.NETFramework[version]configmachine.config
64-bit
%windir%Microsoft.NETFramework64[version]configmachine.config
这篇关于不允许从网络位置加载程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!