![](/img/trans.png)
[英]Crystal Report 13.0.2 giving “Load Report Failed” on web server for some reports while other are working fine
[英]Load Report Failed On Server - Crystal Reports
我有一個水晶報表查看器頁面,可以在我的桌面開發計算機上很好地顯示報表。 我用於此查看器頁面的代碼是:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LoyalitySystem;
using System.Configuration;
using HQ.DatabaseGateway;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
public partial class WebPages_DynamicReports_CrystalReportViewerPage : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
string reportPath = Server.MapPath((string)Utils.GetSessionNavigator(this).GetDataFromCurrentPage(PageParams.Reports.Report));
ReportDocument rep = new ReportDocument();
try
{
if (!File.Exists(reportPath))
{
Response.Write("The specified report does not exist \n");
}
rep.Load(reportPath);
LoadReport(rep);
this.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
this.CrystalReportViewer1.HasToggleGroupTreeButton = false;
this.CrystalReportViewer1.ReportSource = rep;
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
private bool LoadReport(ReportDocument doc)
{
TableLogOnInfo crTableLogonInfo;
Sections crSections;
Database crDatabase;
Tables crTables;
ReportDocument crSubreportDocument;
ReportObjects crReportObjects;
SubreportObject crSubreportObject;
try
{
ConnectionInfo con = new ConnectionInfo();
con.ServerName = ConfigurationManager.AppSettings["dbsource"];
con.DatabaseName = Utils.GetSessionNavigator(this).UserData.DatabaseName;
con.UserID = ConfigurationManager.AppSettings["uid"];
con.Password = ConfigurationManager.AppSettings["pwd"];
crDatabase = doc.Database;
crTables = crDatabase.Tables;
//loop through all the tables and pass in the connection info
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = con;
crTable.ApplyLogOnInfo(crTableLogonInfo);
}
// set the crSections object to the current report's sections
crSections = doc.ReportDefinition.Sections;
// loop through all the sections to find all the report objects
foreach (Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
// loop through all the report objects to find all the subreports
foreach (ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
crSubreportObject = (SubreportObject)crReportObject;
// open the subreport object
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
// set the database and tables objects to work with the subreport
crDatabase = crSubreportDocument.Database;
crTables = crDatabase.Tables;
// loop through all the tables in the subreport and
// set up the connection info and apply it to the tables
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = con;
crTable.ApplyLogOnInfo(crTableLogonInfo);
}
}
}
}
}
catch (Exception e)
{
Response.Write(e.Message);
return false;
}
return true;
}
}
如前所述,這在本地托管我的應用程序時可以很好地工作,但是在生產服務器上,我運行的每個報告都出現“加載報告失敗”,並且通過檢查文件是否存在,可以看到請求的文件是被發現。
我的.aspx標記是:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CrystalReportViewerPage.aspx.cs"
Inherits="WebPages_DynamicReports_CrystalReportViewerPage" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="cr" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>CrystalReportViewer</title>
</head>
<body>
<form id="form1" runat="server">
<cr:CrystalReportViewer ID="CrystalReportViewer1" runat="server" HasCrystalLogo="False" />
</form>
</body>
</html>
我的web.config文件包含:
<sectionGroup name="businessObjects">
<sectionGroup name="crystalReports">
<section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null"/>
</sectionGroup>
</sectionGroup>
<assemblies>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</assemblies>
<buildProviders>
<add extension=".rpt" type="CrystalDecisions.Web.Compilation.RptBuildProvider, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</buildProviders>
而且我已在不同時間在Windows 2008 R2數據中心服務器上同時安裝了CRforVS_redist_install_64bit_13_0_2
和CRforVS_redist_install_32bit_13_0_2
再CRforVS_redist_install_64bit_13_0_2
,並且都無法解決該問題。 該應用程序連接到位於Amazon EC2實例本身上的Amazon RDS SQL Server實例。
我已經在互聯網上搜索了一段時間,以找到解決該問題的方法,但是顯然“ Load Report Failed”消息的含義很廣泛,因此我希望我可以在此問題的特殊情況下提供幫助來解決此問題。
我已經在這個問題上停留了一個多星期,因此,如果能提供任何幫助,我將不勝感激。
此消息通常表明使用提供的路徑無法使用該報告。 如果未安裝運行時,您將收到不同的消息。在您的情況下,所有內容均已正確安裝,但該報告在reportPath + rpName中不可用。 您可以調試並檢查reportPath + rpName是否指向,以及報告是否確實存在。 嘗試使用Path.Combine(reportPath,rpName)-如有必要,它將添加\\。 還檢查IIS是否有權訪問reportPath文件夾中的報告。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.