Friday, June 29, 2012

Microsoft Reportviewer 2010 javascript error

Lately I’ve been looking into Microsoft Reportviewer 2010 for displaying customer reports on an EPiServer site. It’s a quite straight forward task and it should normally not create any problems.

However, deploying the code to the test server did just the opposite, strange issues appeared. When trying to view a report I got a javascript error:

Message: Object required
Line: 2980
Char: 13
Code: 0
URI: http://mydomain/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.30319.1&Name=ViewerScript

Debugging this error I found that it was thrown from the bold line in ReportViewers builtin ViewerScript, where regionElement turned out to be null:

SetSingleRegionVisibility: function(regionElementId, makeVisible)
{
    var regionElement = $get(regionElementId);
    if (makeVisible)
        regionElement.style.display = "";
    else
       regionElement.style.display = "none";
}

Right, now what? I checked everything. I checked that the Reportviewer HTTP handler I had added to my web.config was correct and that all the correct assemblies had been included. I whined about it on Twitter and to a colleague, but whining did surprisingly not fix the error.

I’d taken a look in the GAC several times to check that the assemblies were there as well, but then it suddenly hit me. On the test server, I had installed the Microsoft Reportviewer 2010 redistributables, while on my local machine I found the Microsoft Reportviewer 2010 SP1 redistributables. I updated the assemblies on the test server to SP1 and the problems were solved, hooray!

So much annoyance for so little!