2016-04-25 21 views
0

我想讓我的報表查看器加載水晶報表文件,當我在我的視覺工作室測試它運行良好,但一旦我發佈它,它給了我這個錯誤水晶報表沒有載入已發佈的軟件

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(對象& DocumentPath,的Int32選項) 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(對象& DocumentPath,的Int32選項) 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() - - 在CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() 在CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(字符串文件名,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(); 
我的代碼

我敢肯定它做的加載目錄,因爲它沒有嵌入,但我不知道正確的方式來設置路徑以便它在發佈後找到該文件。

回答

0

嘗試在要運行應用程序的計算機上安裝運行時。

32 bit

64 bit

+0

我剛剛發現我對這個其他線程解決方案https://stackoverflow.com/questions/10833894/a-document-processed-by-the-jrc-engine-cannot-被打開的c-stack –

+0

無論如何,謝謝你,我只是把我的報告文件的內置動作內容 –