cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating a DLL to run SAP Crystal Reports

2,201

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

Accepted Solutions (1)

Accepted Solutions (1)

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...

karan0333
Discoverer
i am facing same issue working with .net core 6 what should I do
karan0333
Discoverer
i am facing same issue working with .NET core 6 what should I do
DonWilliams
Active Contributor
0 Likes
Any Core framework is not supported, must use 4.7 or 4.8 framework. And please don't post to answered posts

Answers (0)