编程之路

——火地晋

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  291 随笔 :: 2 文章 :: 297 评论 :: 134万 阅读

主机信任级别受限security policy,That assembly does not allow partially trusted callers.

http://www.cmszs.com/2010/07/security-policy-that-assembly-does-not-allow-partially-trusted-callers/

 

新写了一个asp.net的测试程序,用到第三方dll文件,放到了godaddy的windows主机上,出现以下异常

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

这是因为很多主机服务商把信任级别设为了Medium,而应用三方dll却需要full信任级别。如果不能让服务商更改信任级别,可以尝试通过以下方法解决。

如果你的dll有源码,打开源代码
更改AssemblyInfo.cs 文件,加入下列代码
using System.Security;
using System.Security.Permissions;
[assembly: AllowPartiallyTrustedCallers]

从新生产dll文件。

 

posted on   火地晋  阅读(1024)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示