<a href="http://www.cmszs.com/2010/07/security-policy-that-assembly-does-not-allow-partially-trusted-callers/">主機信任級别受限security policy,That assembly does not allow partially trusted callers.</a>
<a href="http://www.cmszs.com/2010/07/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/</a>
新寫了一個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://www.cnblogs.com/yelaiju/archive/2012/06/20/2556620.html,如需轉載請自行聯系原作者