【问题标题】:How to set Crystal Report Path which is in other folder in Windows Application如何在 Windows 应用程序的其他文件夹中设置 Crystal Report 路径
【发布时间】:2017-02-05 07:02:07
【问题描述】:

我在项目的根文件夹中有一个带有crystalreportviewer 的表单,我的水晶报表位于“报表”文件夹中。当我尝试加载我的 crystalreprot 时,它显示错误。这是我的代码...

ReportDocument rptDoc = new ReportDocument();
            ds = new InstallationReport();
            ds = PrintInstallationReport();
            ds.Tables[0].Merge(ds.Tables[0]);            
            rptDoc.Load(@"F:\vs10\Windows\RapidDiagnostic\RapidDiagnostic\Reports\InstallationReport.rpt");
            //rptDoc.Load(Application.StartupPath + "\\Reports\\InstallationReport.rpt");
            rptDoc.SetDataSource(ds.Tables[0]);
            crystalReportViewer1.ReportSource = rptDoc;
            crystalReportViewer1.Refresh();

它显示以下错误。 A document processed by the JRC engine cannot be opened in the C++ stack

谁能帮帮我?

【问题讨论】:

  • 你能多贴一点代码吗?例如,如何初始化 rptDoc。另外,如果您能提供错误消息,那将很有帮助。
  • 我认为它在 bin/debug/Reports 中查找可执行文件不是从项目根目录运行的地方
  • 嗨@MikaelKoskinen 我更新了我的问题。

标签: c# winforms crystal-reports


【解决方案1】:

尝试将报告路径更改为您的项目目录:

像这样 ====>>>>

APPPATH = Environment.CurrentDirectory + "Sample.rpt";
CRPT.Load(APPPATH);

确保您的报告属性 => 复制到输出目录 => 复制 if 较新

重建您的项目然后运行。

重建完成后,您将在项目本身的 bin => Debug 文件夹中找到您的水晶报告文件。

请参阅此link 了解更多信息。

【讨论】:

  • 嗨@reds.....它工作但是当我制作安装文件并安装它时。同样的错误又来了。
  • 确保您的水晶报表目录位置与您的开发PC相同。
  • 显示错误....Load Report Failed. A document processed by the JRC engine cannot be opened in the C++ stack
  • 当我检查安装目标文件夹 (C:\Program Files\MyProjectName) 时没有 Reports 文件夹
  • 只需将您的报告包含在您的项目部署文件夹中.. 或者您可以将报告复制并粘贴到那里.. 与您的项目开发 PC 中的目录相同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-07
  • 2021-02-07
  • 1970-01-01
  • 2011-02-06
  • 2014-11-06
  • 1970-01-01
相关资源
最近更新 更多