Wednesday, April 17, 2013

Active Reports "OpenedReport is undefined" or "ViewerViewModel is undefined"

Active Reports is one of the top reporting systems available for .NET, unfortunately it has a couple of major shortcomings.

The first problem is the nearly complete lack of documentation.  It kind of reminds me of the early days of Microsoft Windows and trying to find documentation on any given API call.  Also, while friendly, their support staff seems lacking in basic technical knowledge if anything out of the ordinary goes wrong.

The second problem is the systems focus on windows development.  This focus is so heavy that their web offering has been all but neglected.  They do have a couple of nice viewers for the web, but some of the basic functionality, like exporting, is missing from them; the HTML viewer doesn't even have the ability to print.  All this functionality is supported by the system, but has to be written and added by the developer using the product; a huge shortcoming in my opinion.  This lack of integrated details is consistent throughout the entirety of their web offering.

With the shortcomings out of the way, on to the problem this post is about.  The pesky "OpenedReport" error.  There are lots of posts all over the web about this error, but few people seem to really understand it, and Active Reports staff just point developers to the HttpHandlers setup page to solve the problem.

This error occurs when the page is unable to find or load the primary javascript libraries used by Active Reports.  The "ViewerViewModel" error has the same root cause, it just shows up when using the flash viewer rather than the PdfReader viewer.  Active Reports hosts all of their javascript in a dll called "GrapeCity.ActiveReports.Web.v7" (or whatever version you are using).  The files are then accessed using the following calls to the web server:


 src="Command=ArResource;ScriptId=lib.jquery-1.7.2.min.js.ar7"
 src="Command=ArResource;ScriptId=lib.json2.js.ar7"
 src="Command=ArResource;ScriptId=resources-7.1.7470.0-en-US.js.ar7"
 src="Command=ArResource;ScriptId=RSU-7.1.7470.0.js.ar7"

Those calls can all be seen in the source code for the page.  If you notice all the file extensions end in .ar7 which is not a standard web extension.  This is where the HttpHandlers come in, they are supposed to recognize this extension and redirect it to the correct dll to serve up the desired content.  However, the request must first make it to the asp.net engine in order for the web.config file to be able to handle the request.  This means that IIS must either pass all extensions through to the asp.net engine, or have the .ar7 extension added to it's list.

I am running IIS6, so I went in to the properties for my website, the Home Directory tab and the Configuration button and added a new extension of .ar7 pointing to aspnet_isapi.dll.  If you don't know the path of your dll look at any of the other extensions, almost all of them will point to this dll.  If you wished you could also point them directly to the activereports.web.v7 dll, but I prefer .net to handle all my requests and so pointed it to the generic handler to keep things consistent.

When adding this new extension mapping there are two check boxes which are VERY important.  "Script engine" should be checked, this tells IIS that this is an executable file and to go ahead and run it.  The "Verify that file exists" must be UN-checked; since all the files that active reports will be requesting are virtual files IIS will never be able to find them and would reject all requests for them if this box is checked.

Adding that extension along with the web.config handlers should solve your problem, this is my detailed analysis on this error.

1 comment:

Anonymous said...

Thanks a lot.
Timely help at critical juncture. Much appreciated.