C# – Loading Crystal Report from embedded resource

asp.netccrystal-reports

I have an ASP.NET website and a referenced class library project. In this class library I have a Crystal Report set as embedded resource. I want to load the report dynamically into a CrystalReportViewer.

How do I do it?

Best Answer

I figured out how to solve that problem. When a Crystal Report is added to a Class Library project, it creates a corresponding class, which inherits from ReportClass. An instance of this class can be used as ReportSource of the viewer.

Example:

var report = new CrystalReport1();
report.SetDataSource(datasource);
CrystalReportViewer1.ReportSource = report;