We are frequently having the 32 bit runtime engine (13.0.5) crash while viewing reports. I am able to reproduce the issue by loading a single report and navigating, searching, zooming, etc. and it will eventually crash. I have done this while the only user in the system on a freshly rebooted server. This is the stack trace:
System.ArgumentException: C:\inetpub\wwwroot\Answers\Temp\gszrmcprqezf3chb0h50rwdv130149285071727141.rpt Error Exporting retrying giving up and throwing exception : System.NullReferenceException: Object reference not set to an instance of an object.
at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_IsLoaded()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_FormatEngine()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatTypeformatType, StringfileName)
at Answers.ReportView.UseCrystalUiSave()
The "retrying" is from our code. When we initially encountered this problem we were unable to find either a cause or solution but found that frequently if we tried the operation again it would succeed. Our code looks like this:
//HACK trying a few times before barfing
string rptName = Configuration.Instance.ParameterizedReport.DestinationReportName;
int loops = 20;
for (int i = 0; i < loops; i++)
{
try
{
try
{
ReportDocument rp = (ReportDocument)Session["CurrentReport"];
rp.ExportToDisk(ExportFormatType.CrystalReport, rptName);
break;
}
catch (ParameterFieldCurrentValueException)
{
//we don't care about "Missing Parameter" exceptions, during page life cycle will hit several times
}
}
catch (Exception ex)
{
if (i < 5)
{
// ignore the exception and try again
Elmah.ErrorSignal.FromCurrentContext().Raise(newArgumentException(
String.Format("{0} Error Exporting retrying {1}//{2} : {3}", rptName, i, loops, ex)));
}
else
{
Elmah.ErrorSignal.FromCurrentContext().Raise(newArgumentException(
String.Format("{0} Error Exporting retrying giving up and throwing exception : {1}", rptName, ex)));
throw;
}
}
The error is intermittent and as best as we can determine, not due to disk space or permissions. Usually I can simple re-run the report and continue browsing until it fails again. This code snippet is being called in the Page_Unload event of the report viewer.
If we run the web application in a 64 bit app pool we do not see this issue. However, the 64 bit engine has a serious bug (http://scn.sap.com/thread/3342435) that has forced one or our clients to use the 32 bit engine, where they are now seeing this error and it is blocking work.
We are following the published best practices for closing reports:
reportDoc.Database.Dispose();
reportDoc.Close();
reportDoc.Dispose();
...
_previousReport = null;
GC.Collect();
GC.WaitForPendingFinalizers();
...
this.CrystalReportViewer.Dispose();
this.CrystalReportViewer = null;
The error appears to originate deep in the bowels of CR (get_IsLoaded). I've also seen the CR 2011 designer throw frequent errors when doing a save where it reports it was unable to save under the specified filename and instead gives me a temporary file (I'd hazard a guess that is happens about once every 10-30 saves). A subsequent attempt to save usually succeeds. I suspect the 2 issues are related.