We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

thread safety

Hi,
I just wanted to know if the xlsio library is thread safe.
thanks

8 Replies

MW Melba Winshia Syncfusion Team April 12, 2007 10:57 AM UTC

Hi Atif,

1) Yes, XlsIO is thread safe and it has been tested for use in Server.

2) XlsIO can be used in multithreaded application. Here is the sample for your reference:

http://websamples.syncfusion.com/samples/XlsIO.Windows/59385/main.htm

Kindly let me know if you have any other questions.

Thanks,
Melba


TB Thomas Broman June 5, 2012 12:19 PM UTC

Hi!

I'm evaluating thread safety in XlsIO and I have found that the method ExcelEngine.Excel.Workbooks.Open(string filename) does not appear to be thread safe at all :(. Whenever I run just a single thread everything works fine, but as soon as I start adding multiple threads loading files (not even the same file) all sorts of Exceptions are thrown.

For example:
Syncfusion.Compression.Zip.ZipException was unhandled
  Message=Zip exception.Can't find local header signature - wrong file format or file is corrupt.
  Source=Syncfusion.Compression.Base
  StackTrace:
       at Syncfusion.Compression.Zip.ZipArchiveItem.ReadLocalHeader(Stream stream)
       at Syncfusion.Compression.Zip.ZipArchiveItem.ReadData(Stream stream, Boolean checkCrc)
       at Syncfusion.Compression.Zip.ZipArchive.ExtractItems(Stream stream)
       at Syncfusion.Compression.Zip.ZipArchive.Open(Stream stream, Boolean closeStream)
       at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder..ctor(WorkbookImpl book, Stream stream, String password)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream(Stream stream, String password)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStream(Stream stream, String password, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, Stream stream, ExcelParseOptions options, ExcelVersion version)
       at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, Stream stream, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelOpenType openType)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream)
       at SyncfusionXlsIOTest.Form1.DoThings(Object fileName) in C:\Users\Thomas.EODEV\Documents\Visual Studio 2010\Projects\SyncfusionXlsIOTest\SyncfusionXlsIOTest\Form1.cs:line 93
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart(Object obj)


Or this:
System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
  Source=Syncfusion.XlsIO.Base
  StackTrace:
       at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.GetXmlReaderByContentType(String strContentType, String& strItemName)
       at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseArchiveItemByContentType(String strContentType)
       at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocumentProperties()
       at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocument(List`1& themeColors)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream(Stream stream, String password)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStream(Stream stream, String password, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, Stream stream, ExcelParseOptions options, ExcelVersion version)
       at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, Stream stream, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version, ExcelParseOptions options)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelOpenType openType)
       at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream)
       at SyncfusionXlsIOTest.Form1.DoThings(Object fileName) in C:\Users\Thomas.EODEV\Documents\Visual Studio 2010\Projects\SyncfusionXlsIOTest\SyncfusionXlsIOTest\Form1.cs:line 93
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart(Object obj)


If I put the call to Workbooks.Open() within a lock statement everything works, indicating that the errors are somehow caused by lack of thread safety..?

Any help with this would be much appreciated!


Regards,
Thomas


JM Johnson Monohar M Syncfusion Team June 12, 2012 07:25 AM UTC

Hi Thomas,

Thank you for using Syncfusion products.

We are unable to reproduce the reported error from our side. It would be grateful if you could send us the sample that reproduces the issue for our further investigation. Also, please open a DirectTrac incident for the issue to have a regular followup.

Please let us know if you need any clarification.

Thanks,
Johnson


WH Wendy Hewer July 12, 2012 12:24 PM UTC

Hi

I have also experienced problems when using XlsIO within a multi-threaded application. 
We have a tool which runs reports daily that we have changed to be multi-threaded - the application has been running successfully as a single threaded application for years. As soon as the multi threading was implemented, XlsIO has been throwing the following errors:
  • Block length does not match with its complement.
  • Found invalid data while decoding.
  • Object reference not set to an instance of an object.
  • Unknown block type. Stream might be corrupted.
  • Zip exception.Can't find local header signature - wrong file format or file is corrupt.
  • Zip exception.End of file reached - wrong file format or file is corrupt.
  • Zip exception.Unable to read value at the specified position - end of stream was reached.
  • Zip exception.Wrong Crc value.
  • Root element is missing.
The errors never appear consistently. I have checked the problem does not lie in the Excel templates themselves, as they all run 100% when the threading is removed. The problem is experienced with both XlsIO.Base and XlsIO.ClientProfile.
As Thomas suggested, I implemented SyncLocks around certain problematic lines of code, and this seems to be a good work around as I don't get the errors. 



XlsIOThreadingTest_e41fc5d3.zip


RA Rajesh A Syncfusion Team July 18, 2012 07:29 AM UTC

Hi Wendy Hewer,

Thank you for updating us.

We were able to reproduce the reported issues from our side. This seems to be an enhancement in our product. As we need to log a feature request for the same, we request you to create a new direct-trac incident and request for the enhancement in that. This helps us to proceed further.

Direct-Trac Link: Login

Please let us know if you require any further clarifications.

Thanks,

Rajesh. A

 



NE Neale August 14, 2012 02:40 AM UTC

I wanted to make you aware that we too have experienced numerous thread safety issues with xlsio.  I have spent many hours tracking down these problems and implementing workarounds. It is not a matter of one or two isolated bugs.  I have contacted syncfusion about this in the past and sometimes they seem to have fixed a single instance of the problem but not addressed the many other occurences.  Syncfusion advertise xlsio as thread safe (there is a knowledge base article that states this) when it is clearly not. Therefore this problem is not an enhancement or new feature, it is a bug.  I hope that until syncfusion has thoroughly reviewed and tested xlsio for thread safety, they should make it clear to their customers that xlsio is NOT thread safe.


SJ Stefan Jauch August 14, 2012 02:27 PM UTC

I have exactly the same problems / exceptions when I am using XlsIO version 10.2.0.56 in a multithreaded app; singlethreaded everything works fine...


RA Rajesh A Syncfusion Team August 17, 2012 07:14 AM UTC

Hi Stefan Jauch,

   Thank you for updating us.

Currently we do not provide the support for Multithreading in XlsIO. Whereas, we try to give the solution for your problem in workaround basics. Could you please update us your issue reproducing scenario and we will try to give the solution for this.

Please let us know if you need any clarification.

Thanks and Regards,

Rajesh A.


Loader.
Live Chat Icon For mobile
Up arrow icon