当我尝试boo.exe
从网络共享(映射到驱动器)运行.NET程序集()时,它失败,因为它只是部分信任:
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.我通过在.NET配置中file:///H:/boo-svn/bin/boo.exe
的Evaluate Assembly工具中输入URL 并注意到boo.exe具有Unrestricted权限(在策略之前没有)来验证这一点.
即使有了许可,boo.exe
也不会运行.我仍然得到相同的错误消息.
我该怎么做来调试这个问题?是否有另一种方法可以从网络共享运行"部分受信任"的程序集,而无需为我想要运行的每个程序集更改某些内容?
使用.NET 3.5 SP1,从UNC共享运行的.NET程序集具有完全权限.
请参阅Brad Abrams的Allow .exes以运行网络共享以进行解决方法和讨论,最后后续的.NET 3.5 SP1允许从网络共享启动托管代码.