无法将 System.Web.Extensions 应用于 PartialTrustVisibleAssemblies 列表

Cannot Apply System.Web.Extensions to PartialTrustVisibleAssemblies List

在 webforms .net 4.5 应用程序的 web.config 中,我设置了以下内容:

<trust legacyCasModel="true" level="Full" />

因为这是 Microsoft 解决 asp.net 报告查看器中的错误的解决方法,该错误导致大型报告的生成时间比以前的 .net 版本(3.5 及更早版本)要长得多。不幸的是,启用旧版 CasModel 导致了以下错误。正如错误所暗示的那样,我多次尝试在我网站的 web.config 中应用例外,例如:

<system.web>
        <partialTrustVisibleAssemblies>
            <add assemblyName="System.Web.Extensions" version="4.0.0" publicKey="0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9" />
        </partialTrustVisibleAssemblies>
</system.web>

但是还是报错。我还尝试将此设置应用于 .net 4 web.config 并指定此程序集具有完全信任,但它仍然无法正常工作。我已经阅读了大量与此问题相关的文档,但我找不到任何其他可能解决此问题的方法(除了在我的项目中删除此程序集或对我的 Web 应用程序进行其他重大更改)。非常感谢任何有关如何解决或解决此问题的建议,谢谢。

Server Error in '/' Application. Attempt by security transparent method 'Microsoft.ScriptManager.MSAjaxv45.PreApplicationStartCode.Start()' to access security critical method 'System.Web.UI.ScriptManager.get_ScriptResourceMapping()' failed. Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.MethodAccessException: Attempt by security transparent method 'Microsoft.ScriptManager.MSAjaxv45.PreApplicationStartCode.Start()' to access security critical method 'System.Web.UI.ScriptManager.get_ScriptResourceMapping()' failed. Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.

尝试从引用中删除 "Microsoft.ScriptManager.MSAjax.dll" 和 "Microsoft.ScriptManager.WebForms.dll"(如果未使用)。

@Sachin,谢谢你的回答,但是我需要这个项目的那些程序集,所以不能解决这个问题。我刚才解决了这个问题。我认为这个错误是在应用程序中尝试某些身份验证功能时发生的。我通过将报告功能设置为在新的应用程序池中打开来解决这个问题,这样旧 CAS 模型的启用只会影响新的应用程序池,因此不会影响应用程序中的其他身份验证功能。