开发者

Outlook 2003 add-in - Getting COM exception on application shutdown after creating WPF window

开发者 https://www.devze.com 2022-12-25 03:15 出处:网络
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 t

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 Hanappi


You 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

0

精彩评论

暂无评论...
验证码 换一张
取 消