locked
Cannot Apply System.Web.Extensions to PartialTrustVisibleAssemblies List RRS feed

  • Question

  • User-1604610603 posted

    In the web.config of webforms .net 4.5 application I set the following:

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

    because this is a Microsoft work around to overcome an bug in the asp.net Report Viewer which causes large reports to take much longer to generate than in previous .net versions (3.5 and older). See this post for more details: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/770c24d3-8e48-4310-9459-04601d374958/reportviewer-local-report-10-times-slower-than-same-report-from-report-builder-20?forum=sqlreportingservices.

    Unfortunately, enabling the legacy CasModel has caused the error below. As the error suggests I have attempted many times to apply an exception in my site's web.config such as:

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

    But the error still occurs. I also attempted to apply this setting to the .net 4 web.config and specify this assembly to have full trust but it still won't work. I've read a ton of documentation pertaining to this issue and I cannot locate any other way this issue maybe resolved (except to remove this assembly in my project or make other major changes to my web application). Any suggestions of how I can fix or address this issue would be greatly appreciated, Thanks.

    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=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD
    402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90F
    FD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055
    DA9' 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=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD
    402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90F
    FD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055
    DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.

    Wednesday, March 16, 2016 6:04 PM

All replies

  • User-2057865890 posted

    Hi Gemini6609,

     The following example shows to configure ASP.NET full trust assembly in the fullTrustAssemblies configuration section.

    <system.web> 
    
     <securityPolicy> 
    
     <fullTrustAssemblies> 
    
     <add assemblyName="MyCustomAssembly" version="1.0.0.0" publicKey=" public SigningKey " /> 
    
     </fullTrustAssemblies> 
    
     </securityPolicy> 
    
    </system.web> 
    

    The following example shows to configure ASP.NET a partial-trust assembly in the partialTrustVisibleAssemblies configuration section.

    <system.web>
      <securityPolicy>
        <partialTrustVisibleAssemblies>
    
          <add assemblyName="MyCustomAssembly"
               publicKey="publicSigningKey"/>
    
        </partialTrustVisibleAssemblies>
      </securityPolicy>
    </system.web>
    

    reference:

    ASP.NET Trust Levels and Policy Files

    Best Regards,

    Chris Zhao

    Thursday, March 17, 2016 6:43 AM
  • User-1604610603 posted

    Hi Chris,

    When I apply the securityPolicy element as shown below VS2013 states the error: "The element 'securityPolicy' has invalid child element 'fullTrustAssemblies'. List of possible elements expected: 'trustLevel'." Maybe the fullTrustAssemblies definition is different for asp.net 4.5?  Even the following msdn article does not describe such an option is available for the securityPolicy element: https://msdn.microsoft.com/library/zhs35b56%28v=vs.100%29.aspx

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

    Thursday, March 17, 2016 9:15 PM
  • User-2057865890 posted

    Hi Gemini6609,

    You may have to stay with Net 4.0 and have a try.

    Best Regards,

    Chris Zhao

    Monday, April 11, 2016 8:29 AM