I have a .NET 4.6.2 Windows Forms based application, Visual Studio 2022 which allows a user to run several Crystal Reports.
This Windows form based application runs on the Windows 10/11 Desktop.
Each time a report is run, the following steps are performed.
There is a function called ConfigureCrystalReports
private string ConfigureCrystalReports()
{
_oReportDoc = new ReportDocument();
_oReportDoc.Load(@sReportPath);
_oReportDoc.VerifyDatabase();
_oReportDoc.ExportToDisk(ExportFormatType.CrystalReport, _sTmpReportPath);
_oReportDoc.Close();
_oReportDoc.Dispose();
GC.Collect();
}
Once ConfigureCrystalReports returns
a form which I will call ReportViewerControl is created. The forms wraps the CrystalDecisions.Windows.Forms.CrystalReportViewer.
Each time this ReportViewerControl is created, a CrystalDecisions.Windows.Forms.CrystalReportViewer is created and then the ReportSource is set to the path _sTmpReportPath which represents the path to the exported report file.
oReportViewerCtrl = new ReportViewerControl();
oReportViewerCtrl..SetViewerReport(_sTmpReportPath);
public partial class ReportViewerControl : UserTabbedDocument
{
public ReportViewerControl()
{
InitializeComponent(); // this will create the instance of the CrystalDecisions.Windows.Forms.CrystalReportViewer
}
public void SetViewerReport(string tmpReportPath)
{
crystalReportViewer.Error += CrystalReportViewer_Error;
crystalReportViewer.ReportSource = tmpReportPath;
}
private void CrystalReportViewer_Error(object source, CrystalDecisions.Windows.Forms.ExceptionEventArgs e)
{
string exceptionMsg = e.Exception.ToString();
string innerException = e.Exception.InnerException.ToString();
}
}
So I was on a much earlier release of the Crystal Framework but could always run report multiple reports without issues.
Now after I run 2-3 reports, when the line of code crystalReportViewer.ReportSource = tmpReportPath;
is executed, CrystalReportViewer_Error is called and the information in exceptionMsg and innerException is
CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException: The document is being opened.
at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrappe
To give more back on the overall look and feel of the Window in which the reports are display, every report has a tab. So you can run consecutive reports and each report
gets its own tab with a parent window. This was working find before the upgrade to the SP32 release.