题
当我尝试运行 .NET 程序集时(boo.exe
)从网络共享(映射到驱动器),它会失败,因为它仅部分受信任:
Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at BooCommandLine..ctor()
at Program..ctor()
at ProgramModule.Main(String[] argv)
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
boo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=32c39770e9a21a67
The Zone of the assembly that failed was:
Intranet
The Url of the assembly that failed was:
file:///H:/boo-svn/bin/boo.exe
根据指示 一篇博文, ,我向 .NET 配置添加了一项策略,完全信任所有程序集 file:///H:/*
作为他们的网址。我通过输入 URL 进行了验证 file:///H:/boo-svn/bin/boo.exe
进入 评估装配 .NET 配置中的工具并注意到 boo.exe 有 无限制 许可(该政策之前没有)。
即使得到许可, boo.exe
不运行。我仍然收到相同的错误消息。
我可以做什么来调试这个问题?是否有另一种方法可以从网络共享运行“部分受信任”的程序集,而无需为我想要运行的每个程序集进行更改?
解决方案
在 .NET 3.5 SP1 中,从 UNC 共享运行的 .NET 程序集具有完全权限。
参见布拉德·艾布拉姆斯的 允许 .exe 通过网络共享运行 解决方法和讨论,最后是后续行动 .NET 3.5 SP1 允许从网络共享启动托管代码.
其他提示
我通过使用解决了这个问题 caspol
按照约翰尼·休斯的博客文章中的指示 从网络共享运行 .Net 应用程序:
caspol -addgroup 1.2 -url file:///H:/* FullTrust
看来用于管理策略的 .NET 配置 GUI 根本不起作用。
查看“caspol.exe”程序(随 .NET 运行时提供)。您必须在尝试运行应用程序的计算机上执行此操作。我无法“标记”和组装(可能只有我)。但是,使用 caspol 并为我的应用程序 LocalIntranet_Zone 设置适当的权限,可以解决我的类似问题。
我听说(但尚未尝试过),.NET 3.5 sp1 删除了这一严格的安全要求(默认情况下不允许 .NET 程序集驻留在共享上)。
我想你想添加 允许部分受信任的呼叫者 归因于您的程序集。该错误消息意味着调用 boo.exe 程序集的某些内容不完全受信任,并且 boo.exe 没有允许这样做的属性。