Enhanced Support
asked on
Crystal report from asp.net works then randomly stops
Hi,
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 :-
vb.net code behind in page.load (note the helpers class just provides relevant credentials).
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" />
vb.net code behind in page.load (note the helpers class just provides relevant credentials).
Dim Report As ReportDocument
Report = New ReportDocument
Report.Load(Hosting.HostingEnvironment.MapPath("~/App_reports/report1.rpt"))
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.ApplyLogOnInfo(myTableLogonInfo)
myTable.Location = Helpers.GetConfigSetting("DefaultDatabaseName") & ".dbo." & myTable.Location
Next
CrystalReportViewer1.ReportSource = Report
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
mlmcc
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?
mlmcc
ASKER
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,
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,
ASKER