Hi all,
I'm having an issue with Essential PDF for ASP.net, version 9.304.0.61
In my project, I have a class that generate a big PDF reading some data from entity framework, that sometimes return this exception:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext() at Syncfusion.Pdf.Graphics.Fonts.UnicodeTrueTypeFont.GetDescendantWidth() at Syncfusion.Pdf.Graphics.Fonts.UnicodeTrueTypeFont.SetSymbols(String text) at Syncfusion.Pdf.Graphics.PdfGraphics.ConvertToUnicode(String text, PdfTrueTypeFont ttfFont) at Syncfusion.Pdf.Graphics.PdfGraphics.DrawUnicodeLine(LineInfo lineInfo, RectangleF layoutRectangle, PdfFont font, PdfStringFormat format) at Syncfusion.Pdf.Graphics.PdfGraphics.DrawLayoutResult(PdfStringLayoutResult result, PdfFont font, PdfStringFormat format, RectangleF layoutRectangle) at Syncfusion.Pdf.Graphics.PdfGraphics.DrawStringLayoutResult(PdfStringLayoutResult result, PdfFont font, PdfPen pen, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format) at Syncfusion.Pdf.Graphics.PdfGraphics.DrawString(String s, PdfFont font, PdfPen pen, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format) at ABB.Soc.Manager.PdfExtensions.AddFieldTabbed(PdfPage page, String label, String value, Int32 columns, SizeF size, PointF& currentPoint) in c:\Projects\it-tfsapp1\SOC2\SOC2-Dev\ABB.Soc.Manager\PdfHelper.cs:line 1375 at ABB.Soc.Manager.PdfHelper.SocTableToPdfDoc(User user, Int32 tableRevisionId, PdfDocument& doc) in c:\Projects\it-tfsapp1\SOC2\SOC2-Dev\ABB.Soc.Manager\PdfHelper.cs:line 450
The method that create the PDF is launched on a separated task through Task.Factory.StartNew(...), and generate exception only when launched more then one time, where one of the task (seams a random one, not first or last) finish succesfully and all other have the exception.
This is the method that generate the error:
public static void AddFieldTabbed(this PdfPage page, string label, string value, int columns, SizeF size, ref PointF currentPoint)
{
try
{
page.Graphics.DrawString(label, PdfStyles.LabelHeaderFont, PdfStyles.StandardBrush, currentPoint);
float w = PdfStyles.LabelHeaderFont.MeasureString(label).Width;
currentPoint.X += w;
page.Graphics.DrawString(value, PdfStyles.StandardFont, PdfStyles.StandardBrush, currentPoint);
currentPoint.X -= w;
currentPoint.X += size.Width / columns;
if (currentPoint.X >= size.Width)
{
currentPoint.X = 0;
currentPoint.Y += PdfStyles.StandardFont.Height + (PdfStyles.Margin * 2);
}
}
catch (Exception ex)
{
throw new Soc2Exception("Unexpected error on module Soc2Manager.", System.Reflection.MethodBase.GetCurrentMethod(), ErrorType.Error, ex);
}
}
That is just a my extension used for simplicity.
PdfStyles is static class (does never change), LabelHeaderFont is a PdfTrueTypeFont.
I'm spending hour about this without success, have someone experience with similar issue or now what's wrong with this?