Page 1 of 2

PreCompiled Report

Posted: Tue Apr 30, 2013 6:35 am
by simgschw
Hi,

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:

Code: Select all

public static void LoadCompiledReport(this StiReport report, string path) {
            report = StiReport.GetReportFromAssembly(path);
}
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.

Can you tell why this is happening?

Re: PreCompiled Report

Posted: Thu May 02, 2013 6:38 am
by simgschw
Has anyone an idea to solve my issue???

Re: PreCompiled Report

Posted: Fri May 03, 2013 6:32 am
by Alex K.
Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.

Re: PreCompiled Report

Posted: Mon May 06, 2013 7:24 am
by simgschw
Alright, I tried to create a sample project.

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:

Code: Select all

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);
        }

Re: PreCompiled Report

Posted: Mon May 06, 2013 7:34 am
by simgschw
Alright, I tried to create a sample project.

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:

Code: Select all

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.

Re: PreCompiled Report

Posted: Tue May 07, 2013 1:26 pm
by simgschw
Any ideas?

Re: PreCompiled Report

Posted: Tue May 07, 2013 1:29 pm
by HighAley
Hello.

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:

Code: Select all

        private void testLoadingFromAssembly()
        {
            string path = "Report.mrt";
            string assemblyPath = genAssembly(path);

            //the GetReportFromAssembly method does not load into the current report,
            //this method always create new instance of report from assembly
            XanthosReport report = (XanthosReport)XanthosReport.GetReportFromAssembly(assemblyPath);
        }

        private string genAssembly(string path)
        {
            //change base report type - for newly created reports
            StiOptions.Engine.BaseReportType = typeof(XanthosReport);

            XanthosReport report = new XanthosReport();
            report.Load(path);

            //replace report type in script for already created reports
            report.Script = report.Script.Replace(" : Stimulsoft.Report.StiReport", " : PreCompiledReport.XanthosReport");

            string assemblyPath = path.Replace(".mrt", ".dll");
            report.Compile(assemblyPath);

            return assemblyPath;
        }
Thank you.

Re: PreCompiled Report

Posted: Fri May 10, 2013 10:16 am
by simgschw
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'

Any ideas what could have gone wrong?

Re: PreCompiled Report

Posted: Mon May 13, 2013 1:18 pm
by HighAley
Hello.

Please, send us a sample project which reproduces the issue.

Thank you.

Re: PreCompiled Report

Posted: Tue May 14, 2013 8:45 am
by simgschw
Hi,

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.