提示“该程序集不支持部分受信任的调用方”解决方法

来源:互联网 发布:手机突然没有4g网络 编辑:程序博客网 时间:2024/05/29 09:40

错误  :  

          安全性异常 
说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。 

异常详细信息: System.Security.SecurityException: 该程序集不支持部分受信任的调用方


 参照与大神的解决办法:

                   在.net2.0中,Asp.Net默认在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config中配置了网站的信任级别:

       

      <securityPolicy>
        <trustLevel name="Full" policyFile="internal"/>
        <trustLevel name="High" policyFile="web_hightrust.config"/>
        <trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
        <trustLevel name="Low" policyFile="web_lowtrust.config"/>
        <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
      </securityPolicy>
      <trust level="Full" originUrl=""/>

本来默认是Full级别,但可能服务器供应商出于安全考虑而采用了其他策略。
当前有一种办法,就是在你网站根目录下的web.config中重新声明所选用的策略为Full:

<trust level="Full" originUrl=""/>

它在配置文件中的层次结构如下:

<location allowOverride="true">
    <system.web>
        <trust level="Full" originUrl=""/>
    </system.web>
</location>
location是根元素。

原创粉丝点击