How to Fix "Sys.ArgumentTypeException: Object of type ‘Sys._Application’ cannot be converted to type ‘Sys._Application’." Error

Image representing NewsGator as depicted in Cr...

Image via CrunchBase

In one of my client projects, we kept seeing this error, and basically ignored it for a long time. In our case, we saw the errors specifically on pages that included NewsGator Web Parts and we thought they might be the problem, but it was actually a problem with the SharePoint AJAX settings which NewsGator would have initially installed, but which had been changed many times by other installs and/or people.

A typical full error looked like this:
Sys.ArgumentTypeException: Object of type 'Sys._Application' cannot be converted to type 'Sys._Application'.
Parameter name: instance  ScriptResource.axd?d=3OFwNP2OqissPVnq69wL3hN2bp71o6_alyDiAQ4AtZb7FI9MYnlhIQdNZXDeHZVNPXrWlmYq-0mnuHvEHRe7gW131sU6muSFCaVlWX7ED1k1&t=45c7299c, line 1559 character 43

I did a lot of searching on the Web, of course. Everything I found seemed to be from 2007 or earlier and have to do with asp:ScriptManager. Most of the suggestions said to set the ScriptMode attribute of ScriptManager to Release, so from this:

<%--<asp:ScriptManager ID="ScriptManager1" runat="server" />—%>

to this:

<%--<asp:ScriptManager ID="ScriptManager1" ScriptMode="Release" runat="server" />—%>

This didn’t have any effect for us, unfortunately. FYI – the ScriptManager will be in your master page if you have SharePoint AJAX enabled.

After a *lot* more fishing around (I get tenacious with this stuff once I start – I don’t like to see *any* error messages, because they tend to “cascade” on you.) I found the problem.

In this case, the web.config file had been built up over time with little documentation of the steps involved, who did what, etc.  In other words, pretty much the usual state.  SharePoint had been put out there, its use expanded virally, they tried a lot of different third party things, some of which stayed and others were removed, etc.

Somehow in all of that back and forth, in the line highlighted below, debug had been set to “true”. Setting it to “false” fixed the problem.

<globalization fileEncoding="utf-8" />
    <compilation batch="false" debug="false">
        <add assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <remove expressionPrefix="Resources" />
        <add expressionPrefix="Resources" type="Microsoft.SharePoint.SPResourceExpressionBuilder, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <add expressionPrefix="SPHtmlEncodedResources" type="Microsoft.SharePoint.SPHtmlEncodedResourceExpressionBuilder, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <add expressionPrefix="SPSimpleFormattingEncodedResources" type="Microsoft.SharePoint.SPSimpleFormattingEncodedResourceExpressionBuilder, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <add expressionPrefix="SPUrl" type="Microsoft.SharePoint.Publishing.WebControls.SPUrlExpressionBuilder, Microsoft.SharePoint.Publishing, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />