In our environment we are expecting our users to create packs simultaneously, when doing stress testing I figured out when trying to create two multiple documents together, I get this error,
The given key was not present in the dictionary.
Here is the code,
static void Main(string[] args)
{
aAsposeNew.MultipleInstancesProblem();
Console.ReadLine(); // otherwise it won't going to work
}
public static void MultipleInstancesProblem()
{
try
{
var task1 = Task.Run(() => CreateDocument("document1.pdf"));
var task2 = Task.Run(() => CreateDocument("document2.pdf"));
Console.WriteLine("Done Creating Docs...");
}
catch (Exception error)
{
Console.WriteLine(error.ToString());
}
}
public static void CreateDocument(string documentName)
{
Console.WriteLine(DateTime.Now.ToLongTimeString());
aAsposeUtilities.SetAsposeAPILicense();
var doc = new Document();
doc.Pages.Add();
var table = new Aspose.Pdf.Table();
var row = table.Rows.Add();
table.ColumnWidths = "600";
HtmlFragment hf =
new HtmlFragment(@"<ul>
<li>Internal HR Meeting Outcome</li>
<li>Internal HR Meeting Outcome January 2015</li>
</ul>");
var cell = row.Cells.Add();
cell.Paragraphs.Add(hf);
doc.Pages[1].Paragraphs.Add(table);
doc.ProcessParagraphs();
Page page2 = doc.Pages.Add();
var table2 = new Aspose.Pdf.Table();
table2.ColumnWidths = "600";
var row2 = table2.Rows.Add();
var cell2 = row2.Cells.Add();
cell2.Paragraphs.Add(new TextFragment(@"Document Internal HR Meeting Outcome"));
page2.Paragraphs.Add(table2);
doc.ProcessParagraphs();
Page page3 = doc.Pages.Add();
var table3 = new Aspose.Pdf.Table();
table3.ColumnWidths = "600";
var row3 = table3.Rows.Add();
var cell3 = row3.Cells.Add();
cell3.Paragraphs.Add(new TextFragment(@"Document Internal HR Meeting Outcome January 2015"));
page3.Paragraphs.Add(table3);
doc.ProcessParagraphs();
doc.Save(@"C:\Output\" + documentName);
}
This bug has stopped me to move forward with my project :-(
Thanks