C# - .NET 4.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 ascaspol -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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.NET 4.0 已更改了安全策略的默认规则。您需要为此应用程序创建或修改
App.config
文件。现在,.NET 4.0 中默认忽略代码访问安全性(由
CASPOL
配置)。如果要启用它,您需要将以下内容添加到app.config
文件中:您可以将 .NET 4.0 配置为使用
LoadFrom
将来自网络的代码视为完全可信具有以下配置项:.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 yourapp.config
file:You can configure .NET 4.0 to treat code from the network using
LoadFrom
as fully trusted with the following configuration item: