Hello everyone,
I am creating an application using reactjs as a frontend, asp.net 6.0 as a backend, I want to create report in crystal report and export this report to PDF and Excel using asp.net core web api.
I have written code in asp.net but some error in
ReportDocument reportDocument = new ReportDocument();
I am also sending error screenshot and code below..
Code is below :
public async Task<iactionresult> GenerateReport()
{
try
{
string rootDirectoryPath = _hostingEnvironment.ContentRootPath;
string reportPath = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports" + "\\AccountReport.rpt");
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(reportPath);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
stream.Seek(0, System.IO.SeekOrigin.Begin);
return File(stream, "application/pdf", "report.pdf");
}
catch (Exception ex)
{
return StatusCode(500, $"Internal server error: {ex.Message}");
}
}
Error is below :
FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The system cannot find the file specified.
Please help me to solve this problem..
Thanks
What I have tried:
I have install all related Nuget Packges