Exception while running crystal report on client machine

420 views Asked by At

After installing C# windows application on my client's machine using click once deployment everything is working fine except Reports section where crystal report is being used. I am facing below exception as soon as the report tries to load :

************** Exception Text **************
CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException: The document has not been opened.
   at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.get_ReportAppServer()
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.get_ReportAppServer()
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
   --- End of inner exception stack trace ---
   at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
   at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
   at Application.Screens.Report.cmbAfterSel_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   at System.Windows.Forms.ComboBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Below is the code for cmbAfterSel_SelectedIndexChanged

                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("No data found for the selected criteria", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    CrystalReport1 CR = new CrystalReport1();
                    CR.Load(@"C:\Users\User\Documents\Visual Studio 2010\Projects\Project1\Project1\CrystalReport\CrystalReport1.rpt");
                    CR.SetDataSource(dt);

                    crystalReportViewer1.ReportSource = CR;
                    crystalReportViewer1.RefreshReport();
                }

I have already installed Crystal Reports runtime engine for .net framework.

Ideally the report should open with the data coming from database(SQL server 2012 Express). Reports are working fine in my PC where the development was done.

0

There are 0 answers