您的位置:首页 > 其它

That assembly does not allow partially trusted callers.

2012-06-20 18:16 465 查看
主机信任级别受限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文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐