Page 1 of 1

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Fri Feb 27, 2009 2:43 pm
by dsmeltz
How do you use CreateReportInNewAppDomain?

How do you use it along with the method StiReport.UnloadReportAppDomain?

I'm hoping it loads/runs the compiled report code in a separate app domain, but I'm still having memory issues.

When I try to use these 2 methods I get the following error:

Type 'Stimulsoft.Report.Dictionary.StiRestrictions' in assembly 'Stimulsoft.Report, Version=2008.2.300.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a' is not marked as serializable.


What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Sun Mar 01, 2009 3:14 pm
by Jan
Hello,

Please don't use this methods. Please visit following link:

http://forum.stimulsoft.com/Default.aspx?g=posts&t=142

In this topic you can read how to avoid memory link.

Thank you.

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Mon Mar 02, 2009 6:30 am
by dsmeltz
Unfortunately for us, the referred post really isn't an option. We have too many customer generated custom reports to have them all be precompiled on disk. I guess I'll have to figure out a way to create/tear down my own app domain for loading/running stimul reports.

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Mon Mar 02, 2009 2:17 pm
by Jan
Hello,
Unfortunately for us, the referred post really isn't an option. We have too many customer generated custom reports to have them all be precompiled on disk.
You can do this automatically.
I guess I'll have to figure out a way to create/tear down my own app domain for loading/running stimul reports.
Main problem with app doamin is speed of creation, transfering data (main problem) and transfering rendered report back. Can you say how you get data in report? If you load it from exernal source it have sense.

Thank you.


What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Tue Mar 03, 2009 7:26 am
by dsmeltz
We pull data from a SQL database for our reports.

Yes it is slower, but it's the only reliable way of preventing dynamic Stimul Reports from hanging on to memory.

So what is the 'automatic' way of achieving app domain goodness?

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Tue Mar 03, 2009 1:20 pm
by Jan
Hello,

Sorry i can't reproduce problem which you describe in first post. I have used following code:

Code: Select all

DataSet data = new DataSet();
            data.ReadXml("D:\\demo.xml");

            StiReport report = new StiReport();
            report.Load("d:\\simplelist.mrt");
            report.RegData(data);
            StiReport report2 = report.CreateReportInNewAppDomain();
            report2.Show(true);
            report.UnloadReportAppDomain();
In any case code of this methods is very simple:

Code: Select all

internal AppDomain reportDomain = null;

		public StiReport CreateReportInNewAppDomain()
		{
			AppDomainSetup appDomainSetup = new AppDomainSetup();
			appDomainSetup.ShadowCopyFiles = "false";
			appDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
			AppDomain appDomain = AppDomain.CreateDomain(StiGuidUtils.NewGuid(), AppDomain.CurrentDomain.Evidence, appDomainSetup);
			
			StiReport report = appDomain.CreateInstanceAndUnwrap(this.GetType().Assembly.FullName, this.GetType().FullName)
				as StiReport;

			reportDomain = appDomain;

			report.LoadFromString(this.SaveToString());
            
			foreach (StiData data in this.DataStore)
			{
				report.RegData(data.Name, data.Data);
				report.DataStore[report.DataStore.Count - 1].ViewData = data.ViewData;
			}

			return report;
		}


		public void UnloadReportAppDomain()
		{
			if (reportDomain != null)
			{
				AppDomain.Unload(reportDomain);
				reportDomain = null;
			}
		}
Thank you.

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Tue Mar 03, 2009 1:34 pm
by dsmeltz
It looks like I was calling CreateReportInNewAppDomain too early. I see I have to call that method just before calling Show (Refresh in my case).

I'll rework my code and let you know how it works.

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Tue Mar 03, 2009 2:27 pm
by dsmeltz
It doesn't seem to work very well.

Here's what I'm doing:

_report is loaded with the stimul report:

Code: Select all

StiReport reportInAD = _report.CreateReportInNewAppDomain();
reportInAD.Render();
StiPdfExportService exportServicePDF = new StiPdfExportService();
exportServicePDF.ExportPdf( _report, outputFilename );
_report.UnloadReportAppDomain();
If I do the above, I don't get any exported documents, they contain no pages.

If I do this:

Code: Select all

StiReport reportInAD = _report.CreateReportInNewAppDomain();
reportInAD.Render();
StiPdfExportService exportServicePDF = new StiPdfExportService();
exportServicePDF.ExportPdf( reportInAD, outputFilename );
_report.UnloadReportAppDomain();
(Note I'm trying to use the app domain report, reportInAD, to do the export.)

I receive the following error:

Type 'Stimulsoft.Report.Components.StiPage' in assembly 'Stimulsoft.Report, Version=2008.2.300.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a' is not marked as serializable

What does the method StiReport.CreateReportInNewAppDomain do?

Posted: Thu Mar 05, 2009 2:41 pm
by Jan
Hello,

Export to Pdf use many native dlls imports. I really can't say how it will be work in other domain. Please try following code:

Code: Select all

string str;
StiReport reportInAD = _report.CreateReportInNewAppDomain();
reportInAD.Render();
str = reportInAD.SaveDocumentToString();
_report.UnloadReportAppDomain();
_report.LoadDocumentFromString(str);
_report.ExportDocument(StiExportFormat.Pdf, outputFilename );
Thank you.