none
Cross-Thread problem in VS-2010 office 2010 add-in Project RRS feed

  • Question

  • Hi,

    I have created a project in Visual Studio 2010 with a Office Excel 2010 add-in.

    In that project, I had incuded a .NET based DLL component (this control I have used in past as a routine projects of Visual Studio 2010 -  without office Excel 2010 add-in).

    I have to show some data from that .NET based DLL component.

    So, I transferred that data into a "lblCounter.text".

    While debugging, I am getting an error of Cross-Threading like “Cross-thread operation not valid: Control 'lblCounter' accessed from a thread other than the thread it was created on.”

     In my Normal VS-2010 projects (Same code - without office Excel 2010 add-in), i have never received this kind of error.

    I tried to use invoke method to transfer data, but Excel based project does not have invoke property.

    I also tried to store data into a memory & transferr that memory to label by using a another timer, but same cross-thread error occurs.

    So, please guide me to remove cross-thread problem.

     

    Thank You,

    Dixit

     


    Thursday, December 1, 2011 12:24 PM

Answers

  • Hi Dixit,

     

    Thanks for posting in the MSDN Forum.

     

    I would recommend you use keyword “lock” to prevent several threads handle same instance at the same time. I’m not able to show you more details due to I’m not aware of the operation inside of your DLL component. It will give me great help on further research if you can show me you DLL component’s main snippet.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, December 5, 2011 9:43 AM
    Moderator