We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Parallel.ForEach is giving null exceptions on Aspose.Cells

Hi,

I have tried multiple ways but whenever I use Parallel.ForEach and try to call any methods for aspose, it gives me some wierd exceptions from aspose.cells.

E.g. code

Parallel.ForEach(beginningMsgs, pnlData =>

{

CurrentSheet.Cells.InsertRow(currentRowNum);

});

gives exception as below:

Object reference not set to an instance of an object.

at ‰š‹.›‹..›‹.Œ(Int32 )
at Aspose.Cells.Cell.InsertRows(›š‹ , Int32 , Int32 , Int32 , Worksheet , Boolean )
at Aspose.Cells.RowCollection.InsertRows(Int32 , Int32 , ‡‹ )
at Aspose.Cells.Cells.š(Int32 , Int32 , ‡‹ )
at Aspose.Cells.Cells.InsertRows(Int32 rowIndex, Int32 totalRows)
at Aspose.Cells.Cells.InsertRow(Int32 rowIndex)
AsposeReportGenerator.cs:line 161
at System.Threading.Tasks.Parallel.<>c__DisplayClass2d`2.b__23(Int32 i)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.b__c()

The same code works fine when using

beginningMsgs.ForEach(pnlData =>

{

CurrentSheet.Cells.InsertRow(currentRowNum);

}

);

Does that mean Aspose doesn't support multithreading??

Nirdesh

I am using the latest version 8.0.0.0 dll of Aspose.Cells. However I tried on a few other versions also but same problem.

The same error I am getting on usage of

Task[] taskArray = new Task[beginningMsgs.Count];

for (int i = 0; i < beginningMsgs.Count; i++)

{

var pnlData = beginningMsgs[i];

CurrentSheet.Cells.InsertRow(currentRowNum);

}

at ‰š‹.›‹..›‹.Œ(Int32 )
at Aspose.Cells.Cell.InsertRows(›š‹ , Int32 , Int32 , Int32 , Worksheet , Boolean )
at Aspose.Cells.RowCollection.InsertRows(Int32 , Int32 , ‡‹ )
at Aspose.Cells.Cells.š(Int32 , Int32 , ‡‹ )
at Aspose.Cells.Cells.InsertRows(Int32 rowIndex, Int32 totalRows)
at Aspose.Cells.Cells.InsertRow(Int32 rowIndex)
at AsposeReportGenerator.cs:line 170
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Hi Nirdesh,

Thanks for using Aspose.Cells.

Kindly provide us your sample console application replicating this issue with the latest version. It will help us investigate this issue and we will be able to fix it accordingly.