I'm developing an outlook 2003 add-in. Until now I used only winforms to display one form, but today I've added a WPF window for more complex stuff. DUe to the WPF window, a COM exception is being thrown when outlook shuts down.
Does anybody know why? I need to start a separate thread for the WPF window in single apartment state.
开发者_开发技巧Here is the exception:
System.Runtime.InteropServices.InvalidComObjectException was unhandled
Message="COM object that has been separated from its underlying RCW cannot be used."
Source="PresentationCore"
StackTrace:
at System.Windows.Input.TextServicesContext.StopTransitoryExtension()
at System.Windows.Input.TextServicesContext.Uninitialize(Boolean appDomainShutdown)
at System.Windows.Input.TextServicesContext.TextServicesContextShutDownListener.OnShutDown(Object target)
at MS.Internal.ShutDownListener.HandleShutDown(Object sender, EventArgs e)
InnerException:
Best Regards,
Oliver HanappiYou need to Invoke Shutdown on WPF window Dispatcher in the same thread after the window is closed.
window.Dispatcher.InvokeShutdown();
A similar problem was reported in Microsoft Connect
精彩评论