Avatar of Enhanced Support
Enhanced Support

asked on 

Crystal report from asp.net works then randomly stops


I have a problem with the crystal report viewer control when launched from an asp.net web page.

This will work absolutely fine for several days at a time on the production site, showing various reports correctly, but then they all just stop working, and present the user with a blank page when launched. Obviously the database and credentials, e.t.c do not change, the reports simply will not show until the server is restarted. I do not think it is a memory leak issue because the w3wp.exe service is not using an excessive amount of memory. I have also tried making a call to gc.collect to see if previous reports had been left in memory, but this made no difference. When it stops working, no connection is shown in SQL server activity monitor, so I don't think it's getting as far as a database query.

Developed in visual studio 2008, sql 2008 r2, crystal 2008.

My ASPX page is as per normal blank template with just this :-
<%@ Register Assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"   Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<CR:CrystalReportViewer PrintMode="ActiveX" HasCrystalLogo="False" ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />

Open in new window

vb.net code behind in page.load (note the helpers class just provides relevant credentials).
        Dim Report As ReportDocument
        Report = New ReportDocument

        Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo
        Dim myTables As Tables = Report.Database.Tables
        Dim myTableLogonInfo As New TableLogOnInfo

        With myConnectionInfo
            .ServerName = Helpers.GetConfigSetting("CrystalDSN")
            .DatabaseName = Helpers.GetConfigSetting("DefaultDatabaseName")
            .UserID = Helpers.GetConfigSetting("DatabaseUser")
            .Password = Helpers.GetConfigSetting("DatabasePassword")
            .Type = ConnectionInfoType.SQL
        End With
        For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
            myTableLogonInfo = myTable.LogOnInfo
            myTable.LogOnInfo.ConnectionInfo.AllowCustomConnection = True
            myTableLogonInfo.ConnectionInfo = myConnectionInfo
            myTable.Location = Helpers.GetConfigSetting("DefaultDatabaseName") & ".dbo." & myTable.Location
        CrystalReportViewer1.ReportSource = Report

Open in new window

ASP.NETCrystal Reports

Avatar of undefined
Last Comment
Enhanced Support
Avatar of Mike McCracken
Mike McCracken

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Enhanced Support
Enhanced Support


At what point can I clean up the report objects? I am launching the reports as a separate popup window so they have the full page for the preview (as the rest of my application works from a master page with a standard header/menu) - there is nothing else on the page which displays the report. The code (as posted) therefore runs on page.load but I cannot clean up here as it is needed to display to the user - however if the user just closes the popup browser window, I have no server side event in which to do any cleanup?
You may not be able to and if that is the issue then you may be stuck restarting the server.

There may be ways of cleaning the temp files through scripts but I don't know what they would be.

Why are you using this method of displaying the reports?

Could you spawn a separate application rather than just a page when you want to show a report?

Avatar of Enhanced Support


OK I think I have a solution here. I have found the temp files, but even with a script they cannot be cleaned as they are in use, you were right, it is to do with objects not being released.

I think I can add a collection to the application, instatiated in the application startup in global.asax; when a report is run, I can add it to the collection as a key/value pair; if i find the user is already in the collection, I can get a reference to the report document and release that object from there before adding the new one. I'm pretty sure this will work, thanks for your help,


The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo