Creating reports and dashboards | Stimulsoft community forum
Reporting tool and data analytics tools for creating reports and dashboards in ASP.NET, ASP.NET MVC, .NET Core, Blazor, Angular, PHP, Python, WPF, JavaScript, and Java applications.
I have an own class for reports. this class inherits the methods of stireport. The report itself is created in an appdomain and is unloaded after rendering. In case of some optimizations I tried to precompile the report. this worked in a test project but not in my current project.
Because of the inheritance I had to outsource the StiReport.GetReportFromAssembly(path) method in an extension methods class:
After the method call the dictionary is ok, but after stepping out of this methode the dictionary. especially the variables and the datasources are empty. Further this causes that the rendered report are blank pages.
This project contains a class XanthosReport that inherits from StiReport. XanthosReport uses a static extension methods class(StiReportExtensionMethods). In my case these extension methods are used for static StiReport methods like:
public static void LoadReportFromAssembly(this StiReport report, string path)
{
report = StiReport.GetReportFromAssembly(path);
// result is still ok
System.Console.WriteLine("Datasources count \t" + report.Dictionary.DataSources.Count);
}
This project contains a class XanthosReport that inherits from StiReport. XanthosReport uses a static extension methods class(StiReportExtensionMethods), because some methodes from StiReport return an object of type StiReport and I can't cast these objects in a meaningful way. In my case these extension methods are used for static StiReport methods like:
public static void LoadReportFromAssembly(this StiReport report, string path){
report = StiReport.GetReportFromAssembly(path);
// result is still ok
// datasources' list is greater zero
System.Console.WriteLine("Datasources count \t" + report.Dictionary.DataSources.Count);
}
And as you will see in my sample project, the size of the datasources' list is greater than zero after calling the method published in the code tags, but when I leave this method the datasources' list of the instance of XanthosReport is empty.
For purposes of sampling I used a report from your samples provided.
The problem is in LoadReportFromAssembly(this StiReport report, string path) method. You create a new instance of the StiReport but it is not returned by this method.
There other problem is to cast StiReport to XanthosReport. It's impossible.
The solution of your problem is to use Polymorphism. Please, add next code to the XanthosReport class:
Your suggestion works fine for my test project. In my current project I always get an exception when compile() or render() is called. The exception
Stacktrace:
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile(StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile()
at Grz.Xanthos.Reporting.Common.StimulsoftReporting.ChangeDataSources(XanthosReport report, List`1 paramField, Boolean isOracleDB, Boolean useAntibiogramm) in C:\Projekte_Simone\Grz.Xanthos\Dev\Dev\Sources\Xanthos\Grz.Xanthos.ServiceContracts\Report\Stimulsoft\StimulsoftReporting.cs:line 82
Message:
c:\Benutzer\lrzggsc\Local Settings\Temp\3jkwfhxi.0.cs(241,78) : error CS1502: The best overloaded method match for 'Stimulsoft.Report.StiReport.ToString(object, object, bool)' has some invalid argumentsc:\Benutzer\lrzggsc\Local Settings\Temp\3jkwfhxi.0.cs(241,95) : error CS1503: Argument 2: cannot convert from 'method group' to 'object'
solved the issue by myself. A overriden method named after a stimulsoft systemvariable was in the inheritated class. Unfortunately this system variable is also used in the report. This name clash caused the conflict.