Images missing with the compiled reports

Stimulsoft Reports.WPF discussion
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Images missing with the compiled reports

Post by sandynith »

Hi,
I have found a bug in latest 2016.3 version where images are missing from our reports. This issue was not present with 2016.1 or 2016.2 release.
I have tried 2016.3.8 and issue still exist.
Please find a sample code attached. This is build with Visual Studio 2015 and using Stimulsoft WPF libs: 2016.3.8.

In general, our code is compling reports to an assembly and then using that assembly to call RenderWithWPF:

Code: Select all

report.Load(stiReportTemplate);
report.RegData(dataSet);

report.Compile("", StiOutputType.ClassLibrary, false);   //If we compile the report to assembly then images are missing in 2016.3
// report.Compile();  //Same problem

var assembly = report.CompilerResults.CompiledAssembly;
report = StiReport.GetReportFromAssembly(assembly);
report.RenderWithWpf(false);
If I don't compile the report to assembly then this bug does not happen.

Please see the snapshot to see problem reproduced with the sample project output.
Sti Image bug with compiled reports.jpg
Sti Image bug with compiled reports.jpg (76.96 KiB) Viewed 6207 times
I have seen this post which looks similar but doesn't look like my issue is yet fixed: viewtopic.php?f=12&t=55001

Please let me know if you can see this issue and advise for the same.

Thanks,
Sandeep
Attachments
StiTestReport.7z
Sample code build with VS2015
(4.5 MiB) Downloaded 207 times
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Images missing with the compiled reports

Post by HighAley »

Hello, Sandeep.

Sorry for the delay with answer.
We need additional time to check the issue.
We will answer when we get any result.

Thank you.

Ticket reference: 3144484.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Images missing with the compiled reports

Post by Ivan »

Hello,

Please modify your code:

Code: Select all

report.Load(stiReportTemplate);
report.RegData(dataSet);
report.Compile("", StiOutputType.ClassLibrary, false);

var assembly = report.CompilerResults.CompiledAssembly;
var compiledReport = StiReport.GetReportFromAssembly(assembly);
StiReportResourcesLoader.LoadReportResourcesFromReport(report, compiledReport);
compiledReport.RenderWithWpf(false);
Thank you.
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Re: Images missing with the compiled reports

Post by sandynith »

Hi,

Thanks for your reply. I tried your way and it does work for the sample code provided. Thanks for that.

Couple of Questions and problems:
1. Looks like StiReportResourcesLoader.LoadReportResourcesFromReport is new in 2016.3 as it was not there in previous versions.
May I have some documentaion around it and why its needed?

2. Our real code is somewhat different and it does the following as shown in code snippet (pseudo code)

Code: Select all

//Build Dictionary of Report Asssembly, so that we can reuse same assebly to run report over and over again.
Dictionary<StiReportKey, Assembly> ReportToAssemblyDic = new Dictionary<StiReportKey, Assembly>();

var assembly = ReportToAssemblyDic.GetValueOrDefault(key); 
if (assembly == null)
{
    stiReportTemplate = GetStiReportTemplate() //build report from the .mrt file and set some properties etc.
    report.Load(stiReportTemplate);
    report.RegData(dataSet);
    report.Compile("", StiOutputType.ClassLibrary, false);

    assembly = report.CompilerResults.CompiledAssembly;
    ReportToAssemblyDic.Add(newkey, assembly)  //Add new assembly to the Dictionary
}


//MyGetReortFromAssemblyFunction(assebly)- Our Get report Function, which does following:
myReportFromAssebly = StiReport.GetReportFromAssembly(assembly);
myReportFromAssebly.RenderWithWpf(false);
Essentially we build a dictionary of report assemblies so that we can reuse that assembly to run reports over and over again. (Otherwise you run into assembly memory leak in the app domain issue)
Hence we don't build report template every time we run report.
Which means I do not have 'report' to call in the following function:
StiReportResourcesLoader.LoadReportResourcesFromReport(report, compiledReport);

Hence, I am not sure what is the best way for me to work around this situation.
Please let me know if you understand this situation or if you need more explanation.

Thanks,
Sandeep
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Images missing with the compiled reports

Post by Alex K. »

Hello,

There are two ways to store the image in the assembly of the report:
1) directly in the code, as a Base64 string;
always it works, but report is compile slowly, and have a limit on the size of the images.

2) assembly resource;
due to the .Net Framework compiler all resources must be placed in files on disk. This usually is a big problem in the Web/AspNet due to a lot of restrictions.
Ans was made: if the report is compiled into memory (just using Compile() without a path), the compilation goes without resources, and images are then copied into it from the base report. This gives much less of a problem in the Web/AspNet.
But in your case, it requires additional use StiReportResourcesLoader.

We will discuss the problem and may make the option to force the introduction of resources.

Thank you.
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Re: Images missing with the compiled reports

Post by sandynith »

Thanks for your reply. Please let me know the outcome of your discussion. It will be good for us to have 'the option to force the introduction of resources'
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Images missing with the compiled reports

Post by Alex K. »

Hello,

Ok.
We will let you know about the result in this topic.

Thank you.
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Re: Images missing with the compiled reports

Post by sandynith »

Hi there, is there any update on this please?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Images missing with the compiled reports

Post by Alex K. »

Hello,

We will try to add the new option in the first build after major release which will be available at the end of this month.

Thank you.
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Re: Images missing with the compiled reports

Post by sandynith »

Thanks for the update. I will look into that.
Can't it be included in the coming Major release?
Post Reply