【问题标题】:Running "partially trusted" .NET assemblies from a network share从网络共享运行“部分信任”的 .NET 程序集
【发布时间】:2008-08-23 18:33:55
【问题描述】:

当我尝试从网络共享(映射到驱动器)运行 .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

根据a blog post 的指示,我向 .NET 配置添加了一个策略,该策略完全信任所有以file:///H:/* 作为其 URL 的程序集。我通过在 .NET 配置中的 Evaluate Assembly 工具中输入 URL file:///H:/boo-svn/bin/boo.exe 来验证这一点,并注意到 boo.exe 具有 Unrestricted 权限(它没有有之前的政策)。

即使有权限,boo.exe 也不会运行。我仍然收到相同的错误消息。

我可以做些什么来调试这个问题?是否有另一种方法可以从网络共享运行“部分受信任”的程序集,而无需为我要运行的每个程序集进行更改?

【问题讨论】:

    标签: .net security


    【解决方案1】:

    对于 .NET 3.5 SP1,从 UNC 共享运行的 .NET 程序集具有完全权限。

    请参阅 Brad Abrams 的 Allow .exes to be run off a network shares 以了解解决方法和讨论,最后是跟进 .NET 3.5 SP1 allows managed code to be launched from a network share

    【讨论】:

    • 有趣。 Windows 7 锁定的可执行文件可能通过网络共享、托管或本机运行。
    【解决方案2】:

    我按照 Johnny Hughes 的博文 Running a .Net application from a network share 中的说明使用 caspol 解决了这个问题:

    caspol -addgroup 1.2 -url file:///H:/* FullTrust
    

    用于管理策略的 .NET 配置 GUI 似乎根本不起作用。

    【讨论】:

      【解决方案3】:

      查看“caspol.exe”程序(随 .NET 运行时提供)。您必须在尝试运行应用程序的机器上执行此操作。我无法“标记”和组装(可能只是我)。但是,使用 caspol 并为我的应用 LocalIntranet_Zone 设置适当的权限,可以解决我的类似问题。

      我听说(但还没有尝试过),.NET 3.5 sp1 删除了这个严格的安全要求(默认情况下不允许 .NET 程序集驻留在共享上)。

      【讨论】:

        【解决方案4】:

        我认为您想将AllowPartiallyTrustedCallers 属性添加到您的程序集中。该错误消息暗示调用您的 boo.exe 程序集的某些内容不完全受信任,并且 boo.exe 没有此属性允许它。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-11-25
          • 2010-11-01
          相关资源
          最近更新 更多