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

Killing ExcelEngine.Application.Workbook.Open that is taking longer than X

I currently have a requirement to be able to kill an attempt to open an Excel file (this is also needed for Word and PowerPoint, but will look at Excel first), and when it is taking longer than a preset time limit stop/kill it. Currently I have the attempt to open the Excel file in an individual thread. When I call ExcelOpenThread.Abort(), the thread ends and as part of that calls the ExcelEngine instance dispose method. The issue is when I'm processing a batch of files with multiple files taking longer than the time out limit, the application becomes extremely unstable when I start closing threads. The error that it comes up with is "A heap has been corrupted" error. I've done some investigation in my code and the issue seems to come from the XlsIO library.

The code is the thread is only trying to open the file and set a status on whether it can or can't. If it can't then also capture the reason why.

I've had a look at XlsIO and I can't see a method to say "Stop trying to open that file" or "time out opening after...."

Does anyone have any advice. This ability to stop an attempt to open an Excel file if it is taking longer than the allowed time is a must have for application I'm working on.

I've managed to capture two errors, which are below.

Error 1:
Unhandled exception at 0x000000007791F262 (ntdll.dll) in TestOfficeFilesWithSyncfusion.exe: 0xC0000374: A heap has been corrupted (parameters: 0x0000000077998430).

Error 2:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Syncfusion.XlsIO.Implementation.Heap.HeapFree(IntPtr hHeap, Int32 dwFlags, IntPtr lpMem)
   at Syncfusion.XlsIO.Parser.Biff_Records.IntPtrDataProvider.OnDispose()
   at Syncfusion.XlsIO.Implementation.Collections.RowStorage.Dispose(Boolean disposing)
   at Syncfusion.XlsIO.Implementation.Collections.RecordTable.Dispose()
   at Syncfusion.XlsIO.Implementation.Collections.CellRecordCollection.OnDispose()
   at Syncfusion.XlsIO.Implementation.CommonObject.Dispose()
   at Syncfusion.XlsIO.Implementation.WorksheetImpl.OnDispose()
   at Syncfusion.XlsIO.Implementation.CommonObject.Dispose()
   at Syncfusion.XlsIO.Implementation.WorksheetBaseImpl.Dispose()
   at Syncfusion.XlsIO.Implementation.Collections.WorkbookObjectsCollection.DisposeInternalData()
   at Syncfusion.XlsIO.Implementation.WorkbookImpl.DisposeAll()
   at Syncfusion.XlsIO.Implementation.WorkbookImpl.Close(Boolean SaveChanges, String Filename)
   at Syncfusion.XlsIO.Implementation.WorkbookImpl.Finalize()

3 Replies

SS Sridhar Sukumar Syncfusion Team September 22, 2016 02:55 PM UTC

Hi Gareth, 
 
Thank you for contacting Syncfusion support. 
  
We are unable to reproduce the issue. We have prepared sample as per your scenario and shared it for your reference which can be downloaded from the following location.  
  
  
Workaround: 
 
Kindly change the DataProviderType to ByteArrayDataProvider to overcome this issue. 
 
Code snippet: 
application.DataProviderType = ExcelDataProviderType.ByteArray; 
 
If you face the same issue after applying this approach, kindly refer the sample and share us the modified issue reproducing sample which will be helpful for us to provide prompt solution at the earliest.  
  
Regards,  
Sridhar S 
 



GA Gareth October 6, 2016 01:58 PM UTC

Thanks Sridhar, that work around did the trick.

Gareth


SS Sridhar Sukumar Syncfusion Team October 7, 2016 07:24 AM UTC

Hi Gareth, 

 

Thank you for updating us. 

 

We are glad that issue is resolved at your end. Please let us know if you need any further assistance. 

 

Regards, 

Sridhar S. 

 


SIGN IN To post a reply.
Loader.
Live Chat Icon For mobile
Up arrow icon