Multi threaded calls - error in liscence

Dear,


I’m using aspose.slide version 7.4, I needed to add a multi threaded call to generate simultaneous pptx presentations. All went well except when reading the licence file (SlidesLicense.SetLicense(@“D:\app\aspose\Aspose.Slides.lic”), I get the following error:
Object reference not set to an instance of an object.

Kindly find bellow the code I am using:

private int threadRun;
private void CreateSlide()
{
for (threadRun = 0; threadRun < 5; threadRun++)
{

Thread tid1 = new Thread(new ThreadStart(this.run));
tid1.Start();
}
}
private void run()
{
Aspose.Slides.License SlidesLicense = new Aspose.Slides.License();
SlidesLicense.SetLicense(@“D:\app\aspose\Aspose.Slides.lic”); //<-- this code is where the //error shows

PresentationEx presEx = new PresentationEx(“C:\ASPoseTests\Temp.pptx”);

int slideId = presEx.Slides.AddEmptySlide(presEx.LayoutSlides[0]);
SlideEx sld = presEx.Slides[slideId];

Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 100, 100, 400, 400);

chart.ChartTitle.Text.Text = “Sample Title”;
chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = false;
chart.HasLegend = false;

chart.ValueAxis.IsVisible = false;
chart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;

chart.CategoryAxis.MajorGridLines.Style = LineStyleEx.ThickBetweenThin;

ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “01-02-2013”));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “02-02-2013”));
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “03-02-2013”));
chart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, “04-02-2013”));
chart.ChartData.Categories.Add(fact.GetCell(0, 5, 0, “05-02-2013”));
chart.ChartData.Categories.Add(fact.GetCell(0, 6, 0, “06-02-2013”));

int Id = chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);

ChartSeriesEx series = chart.ChartData.Series[Id];

series.Labels.ShowLeaderLines = true;
int defaultWorksheetIndex = 0;

series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 4, 1, 40));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 5, 1, 30));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 6, 1, 50));

chart.CategoryAxis.RotationAngle = 270;

presEx.Write(“c:\ASPoseTests\ASPoseTests” + threadRun + “.pptx”);
System.Diagnostics.Process.Start(“c:\ASPoseTests\ASPoseTests” + threadRun + “.pptx”);
}

Kindly advise on how I could run the above code without errors.

Thank you in advance,
Sami Simon

H Sami Simon,


I have observed the error shared. Please try calling license in CreateSlide() method before for loop. I have verified on my end and it worked. Please share, if I may help you further in this regard.

Many Thanks,