Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: Sporadic RPC_E_WRONG_THREAD on Dispose()

$
0
0
Hi,

I wanted to thank you for NetOffice, it is a truly fantastic piece of work.

I'm encountering the following error but it's very sporadic and has only happened a couple of times:
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPoint'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B286-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).

at NetOffice.SinkHelper.RemoveEventBinding(Boolean removeFromList)
at NetOffice.SinkHelper.Dispose()
at NetOffice.OutlookApi.Explorer.DisposeEventBridge()
at NetOffice.ComObject.Dispose(Boolean disposeEventBinding)
at NetOffice.ComObject.Dispose()
My code is:
private void AddinShutdown()
        {
                if (this.outlookMailItem != null)
                {
                    this.outlookMailItem.Dispose();
                }

                if (this.outlookExplorer != null)
                {
                    this.outlookExplorer.Dispose();
                }

                if (this.outlookExplorers != null)
                {
                    this.outlookExplorers.Dispose();
                }

                if (this.outlookInspector != null)
                {
                    this.outlookInspector.Dispose();
                }

                if (this.outlookInspectors != null)
                {
                    this.outlookInspectors.Dispose();
                }

                if (this.outlookApplication != null)
                {
                    this.outlookApplication.Dispose();
                }

                if (this.ctpFactory != null)
                {
                    this.ctpFactory.Dispose();
                }
Have you encountered this before and am I doing anything wrong in my code to make this happen?

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>