on 2021 Feb 24 8:19 AM
Hi
We have created an application using .NET5 winforms. Now after reading the article:
https://answers.sap.com/questions/13029137/crystal-reports-for-visual-studio-and-net-core-5-a.html
I understand that I cannot run my reports with .NET5. So, i created a seperate project that uses .NET Framework 4.8 that runs the reports perfectly. However, I now converted the project into a Class Library and linked it into my .NET 5 project. I call the reporting project as follows:
private void sfbtnRun_Click(object sender, EventArgs e)
{
List<ReportParameterModel> rpml = new List<ReportParameterModel>();
ReportParameterModel rpm = new ReportParameterModel() { Seqno = 1, Parameter = "@LocationID", Value = "*" };
rpml.Add(rpm);
ReportingClass rc = new ReportingClass(DataUtility.ConnectionString, "D:\\REW 3.0\\ACTORReports\\ACTORReports\\Reports\\Asset Structure\\Asset Structure.rpt", "Base.sp_Rpt_AssetStructure", rpml);
}
Which will then my DLL and initiate the report:
public ReportingClass(string ConnexString, string ReportFile, string StoredProcedure, List<ReportParameterModel> rpm)
{
ReportDocument rd = new ReportDocument();
string filename = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + RandomString() + ".pdf";
string imagePath = GetReportLogo(ConnexString);
rd.Load(ReportFile);
rd = GetData(rd, ConnexString, StoredProcedure, rpm);
rd.SetParameterValue("imageURL", imagePath);
CrystalReportViewer crv = new CrystalReportViewer();
crv.ReportSource = rd;
crv.Refresh();
rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filename);
System.Diagnostics.Process.Start(filename);
}
However, when I run my .NET5 Application and call the report, i am getting the following error on the "ReportDocument rd = new ReportDocument()" line.
System.TypeLoadException: 'Could not load type 'System.Web.UI.Control' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
How can i get around this issue?
Thanks in advance
Bradley
Hi Bradly,
It's likely a permission issue. And when using SP's you need to set the Parameter values before setting the log on info.
Ping Microsoft to see if calling a 4.8 framework dll is supported.
CR doesn't support it and may have something to do the COM Interopt, CR doesn't like hopping across COM interopts. Objects tend to go out of scope...
It may not work...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.