I am having a problem with a multi-threaded application saving excel workbooks. This problem only occurs on servers with 2 or more CPU’s. If the program is run single threaded or on a server with 1 CPU, I do not have this problem.
Program generates multiple Tabs in an excel workbook on different threads. When all of the threads are done, I run the save command “ExcelFileToSave.Save(strSaveAsFileNameBuild, FileFormatType.Default);”. I intermittently get the follow Exception thrown:
Error: Index was outside the bounds of the array.
Data: System.Collections.ListDictionaryInternal
Target: Void InternalGetReference(Void*, Int32, Int32*)
Stack: at System.Array.InternalGetReference(Void* elemRef, Int32 rank, Int32* pIndices)
at System.Array.SetValue(Object value, Int32 index)
at System.Collections.Hashtable.CopyKeys(Array array, Int32 arrayIndex)
at System.Collections.Hashtable.KeyCollection.CopyTo(Array array, Int32 arrayIndex)
at Aspose.Cells.Record.#.#(Worksheets #)
at Aspose.Cells.Record.#.#(# #, Worksheets #)
at Aspose.Cells.Worksheets.#(# #)
at Aspose.Cells.Worksheets.#(# #)
at Aspose.Cells.Worksheets.#(# #)
at Aspose.Cells.Worksheets.#(FileFormatType#)
at Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType)
at ICE.Net.Reporting.IC_Report.SaveExcelFile(Workbook& ExcelFileToSave) in C:\Documents and Settings\prjdo000\My Documents\Visual Studio 2005\Projects\IC_Report\IC_Report\IC_Report.cs:line 1090
The problem happens less frequently when I sleep the thread just before issuing the save command “Thread.Sleep(100);”.
The longer the sleep, the less frequent I get this exception thrown.