1
votes

I am developping a web application by using the ASP .NET MVC 3 framework.
I have implemented an ASPX page containing a CrystalReportViewer control.

I instantiate a ReportDocument object in my Page_Load event method of my ASPX page.
Then I load a RPT file by using the Load method of my ReportDocument.

My RPT is correctly loaded when I use the VS2010 development web server and I can view it through my viewer.
But the call to the Load method of my ReportDocument raises an exception when I use my IIS 5.1 local web server.

Here are some information about the exception :

  • Exception Type : CrystalReportsException
  • Message : Load report failed
  • StackTrace :

    à CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
    à CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
    à CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
    à ASP.aspnetforms_editionresultats_aspx.Page_Load(Object sender, EventArgs e) dans .aspx:ligne 43
    à System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
    à System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
    à System.Web.UI.Control.OnLoad(EventArgs e)
    à System.Web.UI.Control.LoadRecursive()
    à System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Does someone know why the exception is raised when I use IIS ?

2
First suggestion: try moving your code to Page_InitEmanuele Greco
Do you have the correct Crystal runtimes installed on the server? (version and architecture)Lee Tickett
@EmanueleGreco : I have tried to move my code into the Page_Init event method but I am still facing the exception.user1139666
@LeeTickett : Crystal runtimes are correctly installed on my IIS 5.1 local server. I have got a virtual directory named aspnet_client with correct content under my default web site.user1139666
what credentials (permissions) are IIS and AppPool running under? Where is the .rpt file?Lee Tickett

2 Answers

2
votes

This works for me:

protected void Page_UnLoad(object sender, EventArgs e)
{

        this.CrystalReportViewer1.Dispose();
        this.CrystalReportViewer1 = null;
        // CrystalReportViewer1.Close();
        // CrystalReportViewer1.Dispose();
        GC.Collect();

}
protected void Button1_Click(object sender, EventArgs e)
{
    ReportDocument cryRpt = new ReportDocument();
    cryRpt.Load("C:\\inetpub\\wwwroot\\CrystalReportDemo\\CrystalReport.rpt");
    CrystalReportViewer1.ReportSource = cryRpt;
    CrystalReportViewer1.RefreshReport();
}

}

0
votes

I faced the same problem and what I did to solve the 'Load Report Failed' problem.

  1. First check whether your report folder exists or .rpt files in your project folder after you publish the asp.net project. I simply placed my whole project folder in the IIS root directory. I am using the my reports in 'Reports' folder that doesn't cause any error.
  2. Then copy C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13” into your project main folder like C:\inetpub\wwwroot\YourProjectFolder\.

Please, comment when this doesn't work.