none
Invalid COMObject Exception occuring when word document is closed. RRS feed

  • Question

  • Hi,

    I have a ribbon  application for MSWord plugin. In one of my modules,i have included a multithreading scenario, where,one thread  with apartment state set as STA has been called from inside another parent thread.But after this implementation though I have achieved the intended functionality,but  ,it has generated another exception now.i.e, on close of word  file am getting this COM exception saying "COM object that has been separated from its underlying RCW cannot be used".

    Please suggest  what can be done here.


    Thanks in advance.

    Samjukta


    Thursday, April 10, 2014 11:49 AM

All replies

  • Hi Samjukta,

    I think this thread is specific to Office Dev forum. So I am helping you to move this thread directly into that forum. Thank you for your understanding.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 11, 2014 1:37 AM
  • Hi,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.
    Sorry for any inconvenience and have a nice day!

    Best regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 11, 2014 6:55 AM
  • Hello Samjukta,

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

    It states that you released a COM object which is still used in your code. So, please review your source code.

    See COM object that has been separated from its underlying RCW cannot be used for more information. Also you may find the Error: COM object that has been separated from its underlying RCW cannot be used. calling Excel forum thread helpful.

    Friday, April 11, 2014 9:14 AM
  • Hello Eugene,

    I am including a portion of my code which might be the possible reason behind this COM exception.

    I have a 3 tier architechture here. In my ServiceWrapper class(which makes web service calls), i have  the following snippet that calls my business layer method.

                TResult response = default(TResult);
                retryConnector.ConnectWrapperAndUI();
                if (retryConnector.IsRetryAction)
                {
                    response = Execute(func, out ex);
                }
                return response;


    In my business layer method,i have the following snippet that calls my presentation layer (message box)

                System.Threading.Thread t = new System.Threading.Thread(DisplayMessageBox);
                t.SetApartmentState(System.Threading.ApartmentState.STA);
                t.Start();
                t.Join();
             

    Seems like the COM exception is a result of  calling a new thread from inside  the parent thread.Can you please suggest what changes are to be made to resolve this issue.

    Thanks in advance.

    Samjukta


    Friday, April 11, 2014 12:41 PM
  • Hi,


    From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Jun Zh - MSFT Microsoft Online Community Support

    Tuesday, April 15, 2014 6:29 AM