Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the following code I get the error 'Load report failed' in a dialog box.

C#
public partial class dynamicreporttest : Form
{
    public dynamicreporttest()
    {
        InitializeComponent();
        string reportPath = Application.StartupPath + "\\" + "CrystalReport120514test.rpt";
        crystalReportViewer1.ReportSource = reportPath;

    }
         private void dynamicreporttest_Load(object sender, EventArgs e)
         {
             this.crystalReportViewer1.RefreshReport();
         }
}
Posted

1 solution

try below

C#
ReportDocument reportDocument = new ReportDocument();       
string filePath =Path.Combine(Application.StartupPath, "CrystalReport120514test.rpt");            reportDocument.Load(filePath);
crystalReportViewer.ReportSource = reportDocument; 
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 12-May-14 5:27am    
The file 'CrystalReport120514test.rpt' is in solution explorer.
I tried with the follwoing:
public dynamicreporttest()
{
ReportDocument reportDocument = new ReportDocument();
string filePath = Path.Combine(Application.StartupPath, "CrystalReport120514test.rpt");
reportDocument.Load(filePath);
crystalReportViewer1.ReportSource = reportDocument;
}
private void dynamicreporttest_Load(object sender, EventArgs e)
{
// this.crystalReportViewer1.RefreshReport();
}
I get the an exception at line 'reportDocument.Load(filePath); stating 'load report failed'
DamithSL 12-May-14 5:32am    
in solution explorer, right click on your CrystalReport120514test.rpt file and go to properties, change copy to output directory as "copy if never" or "copy always"
build your solution and run again.
let me know the result :)
S.Rajendran from Coimbatore 12-May-14 5:45am    
I tried both 'copy always' and copy if newer'.
For both I get exception at line 'crystalReportViewer1.ReportSource = reportDocument; '
as 'object reference not set to an instance of an object'.
DamithSL 12-May-14 5:51am    
can you create break point on the line crystalReportViewer1.ReportSource = reportDocument; and check the value you have for filePath, copy that path and manually go and check the file exist on given path or not.
S.Rajendran from Coimbatore 12-May-14 5:57am    
After copying how to go and check the file exist or not

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900