when I generate PDF documents in parallel, AccessViolationException is thrown (if they are not generated in parallel, it works).
I used latest prerelease version of Stimulsoft.NET (8.6.2011). My OS is Windows 7 64-bit.
Exception detail:
Code: Select all
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Drawing
StackTrace:
at System.Drawing.SafeNativeMethods.Gdip.GdipFillRectangle(HandleRef graphics, HandleRef brush, Single x, Single y, Single width, Single height)
at System.Drawing.Graphics.FillRectangle(Brush brush, Single x, Single y, Single width, Single height)
at System.Drawing.Graphics.FillRectangle(Brush brush, RectangleF rect)
at Stimulsoft.Base.Drawing.StiDrawing.FillRectangle(Graphics g, Brush brush, RectangleD rect)
at Stimulsoft.Base.Drawing.StiDrawing.FillRectangle(Graphics g, StiBrush brush, RectangleD rect)
at Stimulsoft.Report.Components.StiCheckBox.GetMetafile()
at Stimulsoft.Report.Export.StiPdfExportService.AssembleCheckbox(StiComponent component)
at Stimulsoft.Report.Export.StiPdfExportService.ExportPdf(StiReport report, Stream stream, StiPdfExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, StiExportService exportService, Stream stream, StiExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, Stream stream, StiExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, String file, StiExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, String file)
Code: Select all
static void Main(string[] args)
{
Enumerable.Range(1, 20).AsParallel()
.WithDegreeOfParallelism(10)
.WithExecutionMode(ParallelExecutionMode.ForceParallelism)
.ForAll(i =>
{
try
{
byte[] template = File.ReadAllBytes("C:\\template.mrt");
byte[] document = File.ReadAllBytes("C:\\document.xml");
Console.WriteLine("Rendering document ID={0}", i);
var report = RenderReport(template, document);
report.ExportDocument(StiExportFormat.Pdf, "C:\\output" + i + ".pdf");
Console.WriteLine("{0} Number of pages: {1}", i, report.RenderedPages.Count);
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception: {1}", i, ex.Message);
}
});
Console.WriteLine("Finished");
Console.ReadLine();
}
private static StiReport RenderReport(byte[] template, byte[] document)
{
StiReport report = new StiReport();
report.Load(template);
DataSet ds = new DataSet();
ds.ReadXml(new MemoryStream(document));
report.Dictionary.DataStore.Clear();
report.Dictionary.Databases.Clear();
report.RegData("Connection", ds);
report.Dictionary.Synchronize();
report.Render(false);
return report;
}
Code: Select all
System.InvalidOperationException was caught
Message=Hashtable insert failed. Load factor too high. The most common cause is multiple threads writing to the Hashtable simultaneously.
Source=mscorlib
StackTrace:
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.set_Item(Object key, Object value)
at Stimulsoft.Base.Drawing.StiTextRenderer.ParseColor(String colorAttribute)
at Stimulsoft.Base.Drawing.StiTextRenderer.ParseHtmlTag(String tag, StiHtmlState& state, ArrayList stack)
at Stimulsoft.Base.Drawing.StiTextRenderer.ParseHtmlToStates(String inputHtml, StiHtmlState baseState)
at Stimulsoft.Base.Drawing.StiTextRenderer.DrawTextBase(Graphics g, String& text, Font font, RectangleD bounds, Color foreColor, Color backColor, Double lineSpacing, StiTextHorAlignment horAlign, StiVertAlignment vertAlign, Boolean wordWrap, Boolean rightToLeft, Double scale, Double angle, StringTrimming trimming, Boolean lineLimit, SizeD& measureSize, Boolean needDraw, ArrayList textLinesArray, ArrayList textLinesInfo, Boolean allowHtmlTags, ArrayList outRunsList, ArrayList outFontsList)
at Stimulsoft.Base.Drawing.StiTextRenderer.MeasureText(Graphics g, String text, Font font, RectangleD bounds, Double lineSpacing, Boolean wordWrap, Boolean rightToLeft, Double scale, Double angle, StringTrimming trimming, Boolean lineLimit, Boolean allowHtmlTags)
at Stimulsoft.Report.Components.StiWysiwygTextRender.MeasureString(Double width, Font font, StiText textBox)
at Stimulsoft.Report.Components.StiText.GetActualSize()
at Stimulsoft.Report.Components.StiContainerHelper.CheckSize(StiComponent component)
at Stimulsoft.Report.Engine.StiContainerV2Builder.InternalRender(StiComponent masterComp)
at Stimulsoft.Report.Components.StiComponent.InternalRender()
at Stimulsoft.Report.Engine.StiComponentV2Builder.Render(StiComponent masterComp)
at Stimulsoft.Report.Components.StiComponent.Render()
at Stimulsoft.Report.Engine.StiContainerV2Builder.InternalRender(StiComponent masterComp)
at Stimulsoft.Report.Engine.StiBandV2Builder.InternalRender(StiComponent masterComp)
at Stimulsoft.Report.Components.StiComponent.InternalRender()
at Stimulsoft.Report.Engine.StiEngine.InternalRenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents, Boolean& isChildsEnabled)
at Stimulsoft.Report.Engine.StiEngine.RenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents)
at Stimulsoft.Report.Engine.StiEngine.RenderBand(StiBand band)
at Stimulsoft.Report.Engine.StiPageHelper.RenderPage(StiPage page)
at Stimulsoft.Report.Engine.StiRenderProviderV2.RenderReport(StiReport report, StiReport masterReport, StiRenderState state)
at Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(Boolean showProgress, Int32 fromPage, Int32 toPage)
at Stimulsoft.Report.StiReport.Render(Boolean showProgress)