在客户端计算机上运行Crystal Report时发生异常

时间:2019-04-22 14:42:57

标签: c# visual-studio-2010 crystal-reports-2010 sql-server-2012-express

使用单击一次部署在我的客户端计算机上安装C#Windows应用程序后,部署工作一切正常,除了使用水晶报表的“报表”部分。报表尝试加载后,我将面临以下异常:

************** 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)

下面是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();
                }

我已经为.net框架安装了Crystal Reports运行时引擎。

理想情况下,报告应使用来自数据库(SQL Server 2012 Express)的数据打开。在完成开发的PC上,报告运行良好。

0 个答案:

没有答案