locked
Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'. RRS feed

  • Question

  • I am using .net framework 2.0

    I got a website application from my friend which was in .net framework 3.5

    I converted all settings to 2.0

    When I introduced the code for using webservice I got following runtime error.

    Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.

    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.InvalidCastException: Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidCastException: Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.]
    System.Web.Configuration.ApplicationSettings.EnsureSectionLoaded() +73
    System.Web.Handlers.ScriptResourceHandler.IsCompressionEnabled(HttpContext context) +10
    System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +24
    System.Web.Handlers.ScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +49
    System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +163
    System.Web.UI.ScriptReference.GetUrl(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +189
    System.Web.UI.ScriptManager.RegisterScripts() +506
    System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +107
    System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8698462
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

    ibm@cd
    Monday, July 11, 2011 6:05 AM

Answers

  • You mentioned you switched version from 3.5 to 2.0 of the .NET Framework, it may be some references that are not updated and it doesn't allow you to cast from the 2.0 version of class to 3.5 version, or other way around. Check all references to system assemblies to be for 2.0 if that is what you want to use.
    • Proposed as answer by Paul Zhou Wednesday, July 13, 2011 7:40 AM
    • Marked as answer by Paul Zhou Monday, July 18, 2011 9:46 AM
    Monday, July 11, 2011 2:34 PM

All replies

  • You mentioned you switched version from 3.5 to 2.0 of the .NET Framework, it may be some references that are not updated and it doesn't allow you to cast from the 2.0 version of class to 3.5 version, or other way around. Check all references to system assemblies to be for 2.0 if that is what you want to use.
    • Proposed as answer by Paul Zhou Wednesday, July 13, 2011 7:40 AM
    • Marked as answer by Paul Zhou Monday, July 18, 2011 9:46 AM
    Monday, July 11, 2011 2:34 PM
  • I solved the problem by replacing the AjaxControlToolkit.dll in the Bin directory with a new one.

    The AjaxControlToolkit must match the System.Web.Extention in the web.config

    So System.Web.Extensions,     Version=3.5.0.0 goes with AjaxControlToolkit.dll 3.0

    And System.Web.Extensions,     Version=1.0.0.0 goes with AjaxControlToolkit.dll 1.0

    Thursday, July 16, 2015 6:18 PM