我用.net4.0在vs2010中创建了一个水晶报告。当我发布网站时,它会抛出错误“无法在 C++ 堆栈中打开由 JRC 引擎处理的文档”。我在服务器上发布了该网站,并尝试从客户端访问它,我确实在 app_code 中保留了 .rpt 文件,但再次遇到相同的错误。所以我创建了一个文件夹 wwwroot 并在该文件夹中保存了 asp_client 和 website 文件夹,并提供了 wwwroot 的物理路径。一切正常,除了水晶报告。在.cs文件中代码如下:
ReportDocument rptDoc = new ReportDocument();
DataSetForCrystalReport ds = new DataSetForCrystalReport();
DataSetForCrystalReport dsHeader = new DataSetForCrystalReport();
DataTable dt = new DataTable();
DataTable dtHeader = new DataTable();
dt.TableName = "dtBill";
string ReceiptNo = Request.QueryString["ReceiptNo"];
dt = getAllOrders(ReceiptNo).Tables[0];
dtHeader = TblcompanysettingsService.GetOrganizationDetails();
ds.Tables[1].Merge(dt);
ds.Tables[2].Merge(dtHeader);
rptDoc.Load(Server.MapPath("crBill.rpt"));
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptDoc;
错误堆栈跟踪:
[COMException (0x80041811): Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.]
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +147
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +422
[CrystalReportsException: Load report failed.]
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +549
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1613
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +189
GenerateBill.Page_Load(Object sender, EventArgs e) in e:\ShareFolder\Movie\wwwroot\Website\GenerateBill.aspx.cs:33
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064