主机信任级别受限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文件。
出处: http://yelaiju.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。