Posted 17 May 2018, 6:34 am EST
I just saw your sample, in our case, since the same application will be instantiated multiple times, both Run and Export methods will be running concurrently in different AppDomains, I changed the MergeReport to the code below then the exception was thrown (small numbers on k didn’t throw exception but when I changed to 50 it did):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GrapeCity.ActiveReports.Document;
using System.Threading;
using GrapeCity.ActiveReports;
using System.Xml;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace ImageExceptionApp
{
class MergeReport
{
int t;
int k;
object locker;
public void Run()
{
t = 0;
k = 50;
locker = new Object();
Parallel.For(0, k, i=>CreateDocument());
}
static int I = 0;
public void CreateDocument()
{
try
{
SectionReport report = new SectionReport();
XmlReader xmlR = null;
string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\..\..\..\Resources\template.rpx";
xmlR = new System.Xml.XmlTextReader(path);
report.LoadLayout(xmlR);
xmlR.Close();
report.Run();
GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdf = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
pdf.Export(report.Document, "test" + I++.ToString() + ".pdf");
}
catch (Exception ex)
{
throw ex;
}
}
}
}
Thanks again