1

在 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 应用程序进行其他重大更改)。任何有关如何解决或解决此问题的建议将不胜感激,谢谢。

“/”应用程序中的服务器错误。尝试通过安全透明方法“Microsoft.ScriptManager.MSAjaxv45.PreApplicationStartCode.Start()”访问安全关键方法“System.Web.UI.ScriptManager.get_ScriptResourceMapping()”失败。程序集“System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”是一个有条件的 APTCA 程序集,在当前 AppDomain 中未启用。要使该程序集被部分信任或安全透明代码使用,请添加程序集名称“System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain. 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。异常详细信息:System.MethodAccessException:尝试通过安全透明方法“Microsoft.ScriptManager.MSAjaxv45.PreApplicationStartCode.Start()”访问安全关键方法“System.Web.UI.ScriptManager。get_ScriptResourceMapping()' 失败。程序集“System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”是一个有条件的 APTCA 程序集,在当前 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. Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 是一个有条件的 APTCA 程序集,在当前 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. Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 是一个有条件的 APTCA 程序集,在当前 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. 是在当前 AppDomain 中未启用的有条件 APTCA 程序集。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. 是在当前 AppDomain 中未启用的有条件 APTCA 程序集。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.

4

2 回答 2

0

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

于 2016-09-14T14:21:34.730 回答
0

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

于 2016-09-14T14:51:53.837 回答