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:


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 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 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.

Monday, April 15, 2013

Blank page in Active Reports using flash viewer

I started using Active Reports for the first time and wanted to try out the various viewers.  After spending hours trying to figure out why the flash viewer was not showing anything but a blank page I started to be convinced that there was a problem with the plugin in my browser.

So, I downloaded a free swf video off the net and hard coded some HTML to display it on my page.  When that worked I returned to troubleshooting Active Reports itself.  Viewing the source for my page I found my hard coded flash code and compared with with the auto generated flash code from Active Reports.

Every help site I had been to said to put the Active Report swf files ( there are two of them ) into the root of your application, which is where mine were.  Looking at the HTML output however, I noticed that it was actually looking for them in the same folder that the page was being executed it; which was not the root of my site.  Moving the two swf files and related Theme folder into the correct sub-directory everything started to work.

Edit: I recently ran into a similar version of this problem.  I published a website after first deleting all the files in the destination directory.  When I ran the report using the HTML viewer I got the error "Failed to send request to ./ActiveReports.ReportService.asmx/RunReport - Internal Server Error".  One guy said a handler issue caused this problem for him.  In my case it was the actual .asmx file that was missing since it never actually got published.  As soon as I copied it into the destination directory things started working again.