C# - .NET 4.0 - 该程序集不允许部分受信任的调用者

发布于 2024-10-04 05:28:04 字数 573 浏览 5 评论 0原文

从网络共享运行时,我的应用程序抛出以下异常:

该程序集不允许部分受信任的调用者。

我的应用程序引用两个 DLL 文件:

  • BitFactory.Logging.dll
  • FileHelpers.dll

我不确定哪一个有问题。

  • AllowPartiallyTrustedCallersAttribute:仔细阅读,但我没有这两个 DLL 文件的源代码,因此我无法将该属性添加到这些 DLL 文件中。

  • CASPOL.EXE:使用一些变体添加了我的网络共享,例如caspol -machine -addgroup 1. -url \\netserver\netshare\* LocalIntranet无似乎有影响。

我之前在 .NET 3.5 中使用过 CASPOL hack,但是现在它似乎不适用于 .net 4.0。任何人都可以建议我如何绕过这个“部分受信任的呼叫者”检查吗?

谢谢。

When running from a network share, my application throws the following exception:

That assembly does not allow partially trusted callers.

My application references two DLL files:

  • BitFactory.Logging.dll
  • FileHelpers.dll

I'm not sure which one it is having problems with.

  • AllowPartiallyTrustedCallersAttribute: Read up on it, but I do not have the source for either of the DLL files, so I'm not able to add the attribute to those DLL files.

  • CASPOL.EXE: added my network share using a few variations, such as caspol -machine -addgroup 1. -url \\netserver\netshare\* LocalIntranet nothing seems to affect.

I've used CASPOL hack before, with .NET 3.5, however, it seems to not work with .net 4.0 now. Can anyone suggeest on how I can bypass this "Partially Trusted Caller" check?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撞了怀 2024-10-11 05:28:04

.NET 4.0 已更改了安全策略的默认规则。您需要为此应用程序创建或修改 App.config 文件。

现在,.NET 4.0 中默认忽略代码访问安全性(由 CASPOL 配置)。如果要启用它,您需要将以下内容添加到 app.config 文件中:

<configuration>
   <runtime>
      <!-- enables legacy CAS policy for this process -->
      <NetFx40_LegacySecurityPolicy enabled="true" />
   </runtime>
</configuration>

您可以将 .NET 4.0 配置为使用 LoadFrom 将来自网络的代码视为完全可信具有以下配置项:

<configuration>
   <runtime>
      <!-- Treat assemblies from network locations as fully trusted. -->
      <!-- Caution: Do not point this loaded gun at your foot. -->
      <loadFromRemoteSources enabled="true" />
   </runtime>
</configuration>

.NET 4.0 has changed the default rules for security policy. You'll need to create or modify the App.config file for this application.

Code access security (as configured by CASPOL) is now ignored by default in .NET 4.0. If you want to enable it you need to add the following to your app.config file:

<configuration>
   <runtime>
      <!-- enables legacy CAS policy for this process -->
      <NetFx40_LegacySecurityPolicy enabled="true" />
   </runtime>
</configuration>

You can configure .NET 4.0 to treat code from the network using LoadFrom as fully trusted with the following configuration item:

<configuration>
   <runtime>
      <!-- Treat assemblies from network locations as fully trusted. -->
      <!-- Caution: Do not point this loaded gun at your foot. -->
      <loadFromRemoteSources enabled="true" />
   </runtime>
</configuration>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文