I trying to create an application in c# with Crystal Report and then I create setup file using publish wizard and delivery to my client.
Now I use following code to bind crystal report in c#.
ReportDocument doc = new ReportDocument();
doc.Load("D//CrystalReport1.rpt",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);
doc.SetDataSource(dt);
crystalReportViewer1.ReportSource = doc;
crystalReportViewer1.Refresh();
At client Side generate following error.
fmPrint Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately. Load report failed CrystalDecisions.shared.CrystalReportsException: Load report failed → System Run... at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(... at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object... at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocum... — End of inner exception stack trace — at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocum...
'Load report failed.' exception occurs when the path specified for the .rpt file is incorrect. Please check the file path again. Also try the below code.
When working for web
doc.Load(Server.MapPath("\\CrystalReport1.rpt")",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
Prefer to put the .rpt file in a folder and also specify the folder location.For eg.
Make a Folder Reports inside solution and consolidate all the .rpt files inside the folder
doc.Load(Server.MapPath("\\Reports\\CrystalReport1.rpt")",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
When working for window
doc.Load(@"D//CrystalReport1.rpt",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
trying using with a sign '@'. Hope it helps!