Reputation: 1697
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 :
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 ?
Upvotes: 1
Views: 6809
Reputation: 212
I faced the same problem and what I did to solve the 'Load Report Failed' problem.
.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. 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.
Upvotes: 0
Reputation: 21
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();
}
}
Upvotes: 2