Crystal报表未加载已发布的软件

时间:2016-04-25 11:18:15

标签: c# crystal-reports

我想让我的报表查看器在winforms上加载一个水晶报表文件,当我在我的visual studio上测试时它运行得很好,但是一旦我发布它,它就会给我这个错误

 See the end of this message for details on invoking 

实时(JIT)调试而不是此对话框。

**************例外文字************** CrystalDecisions.Shared.CrystalReportsException:加载报告失败。 ---> System.Runtime.InteropServices.COMException:不支持的操作。由JRC引擎处理的文档无法在C ++堆栈中打开。    在CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath,Int32 Options)    在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath,Int32 Options)    在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()    ---内部异常堆栈跟踪结束---    在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()    在CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename,OpenReportMethod openMethod,Int16 parentJob)    在CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String

以下是用于加载报告文件的代码

 ReportDocument cryRpt = new ReportDocument();
        TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        Tables CrTables;

        PayrollRep payrollrep = new PayrollRep();


        string myreportname = payrollrep.Name;

        cryRpt.Load(Application.StartupPath + "\\PayrollRep.rpt");
        ////cryRpt.Load("PayrollRep.rpt");

        crConnectionInfo.ServerName = "xxxxx";
        crConnectionInfo.DatabaseName = "xxxx";
        crConnectionInfo.UserID = "xxxx";
        crConnectionInfo.Password = "xxxx";

        CrTables = cryRpt.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            crtableLogoninfo = CrTable.LogOnInfo;
            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
            CrTable.ApplyLogOnInfo(crtableLogoninfo);
        }

        crystalReportViewer1.ReportSource = cryRpt;
        crystalReportViewer1.Refresh();

我很确定它与load目录有关,因为它没有嵌入,但我不知道设置路径的正确方法,以便在发布后找到文件。

1 个答案:

答案 0 :(得分:0)

尝试在要运行应用的计算机上安装运行时。

32 bit

64 bit