Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Object reference error when opening Xlsx on multi threads

Last post 02-11-2010, 1:36 AM by nausherwan.aslam. 6 replies.
Sort Posts: Previous Next
  •  02-08-2010, 11:40 AM 221262

    Object reference error when opening Xlsx on multi threads .NET

    I am evaluating Aspose.Cells for our project need.
    I have a simple application to open workbook, set few cells, and calculate a formula and read the value.

    So i am using code like
    var workbook = workbook.Open("my.xlsx")
    workbook.Worksheets[0].Cells["A2"].PutValue(10);
    workbook.CalculateFormula();

    When I run this code with Single thread 50 times, it works fine.
    When i the code on multiple threads, it throws error on Workbook.Open method on different cells each time, saying

    Object reference not set to an instance on Cell [D2]

    each time, its different cell. Does Aspose.Cell work in multiple threading environment?

    And is there any way to cache Opened workbook / sheet, and use as separate copy on thread? so calculation of formula works fine on all threads concurrently?

    thanks.
     
  •  02-08-2010, 12:18 PM 221271 in reply to 221262

    Re: Object reference error when opening Xlsx on multi threads

    Hi,

     Well, Aspose.Cells for .NET is a pure .NET component that is written in managed C#. So, there is not problem with the component using it concurrently in multi-threads. Bur, for your info, to save memory, there is a global shared string table in an Excel file. So if you change a single workbook data by opening it concurrently in multi-threads, the result might be unstable. There is also a global section in an Excel file which contains global information of drawing objects and other information etc. So, if you want to change the objects settings concurrently in multi-threads, the result might be unstable too. It is to be noted here, this is the limitation of MS Excel formats and nothing to do with Aspose.Cells for .NET component. So, the best way to utilize multi-threading is to create separate Workbook objects in each thread. Your application can handle multi-workbooks at the same time but please don't handle a single Excel file in multi-threads.

    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-08-2010, 12:49 PM 221275 in reply to 221271

    Re: Object reference error when opening Xlsx on multi threads

    Thanks for the reply Amjad.

    I am opening new workbook object on each thread separately by calling Workbook.Open. But since its same excel file that am trying to open, it throws this error randomly on few threads.

    I am not using any global information. Since I am creating new workbook on each thread, it should not throw any error. But for some reason, I think Aspose cells keeps shared memory across threads.
     
  •  02-09-2010, 1:10 AM 221357 in reply to 221275

    Re: Object reference error when opening Xlsx on multi threads

    Hi,

    Thank you for considering Aspose.

    Please create a sample project, zip it and post it here with template files to reproduce the issue. We will check it soon.

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-09-2010, 5:46 PM 221536 in reply to 221357

    Re: Object reference error when opening Xlsx on multi threads

    Attachment: Present (inaccessible)
    I have attached sample windows application. It is failing on random places when running with multi threading.

    thank you.
     
  •  02-10-2010, 1:40 AM 221583 in reply to 221536

    Re: Object reference error when opening Xlsx on multi threads

    Hi,

    Thank you for considering Aspose.

    We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id CELLSNET-14272.

    Thank you & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  02-11-2010, 1:36 AM 221820 in reply to 221536

    Re: Object reference error when opening Xlsx on multi threads

    Attachment: Present (inaccessible)

    Hi, 

     

    Thank you for considering Aspose.

     

    Please try the attached latest version of Aspose.Cells for .NET. We have fixed your mentioned issue regarding multi threading.

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
View as RSS news feed in XML