You must Sign In to post a response.
  • Category: .NET

    "COM object that has been separated from its underlying RCW cannot be used."

    I am using Task class to execute function. In that function I am using xlWorkSheet which i had created before calling the function.

    I am getting below error during this activity.

    COM object that has been separated from its underlying RCW cannot be used.
  • #767156
    It's somewhat hard to tell what your actual application is doing, but it sounds like you may be instantiating the COM object and then attempting to access it from another thread, perhaps in a Timer.Elapsed event. If your application is multithreaded, you need to instantiate the COM object within each thread you will be using it in.
    A good way to debug this issue is to do the following:
    1.Write a class that inherits from the Interop class (otherwise known as the runtime callable wrapper or RCW).
    2.Override DetachEventSink
    3.Override Dispose
    4.Call your new class instead of calling the interop class directly
    5.Add breakpoint to DetachEventSink and Dispose
    6.See who is calling these methods out of order

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments