Outlook 2003加载项 - 在创建WPF窗口后,在应用程序关闭时获取COM异常

Oli*_*ppi 5 .net com outlook vsto exception

我正在开发一个outlook 2003加载项.到目前为止,我只使用winforms来显示一个表单,但今天我为更复杂的东西添加了一个WPF窗口.DUe到WPF窗口,当outlook关闭时抛出COM异常.

有人知道为什么吗?我需要在单个单元状态下为WPF窗口启动一个单独的线程.

这是一个例外:

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: 
Run Code Online (Sandbox Code Playgroud)


诚挚的问候,Oliver Hanappi

Dee*_*k N 2

窗口关闭后,您需要在同一线程中调用 WPF 窗口调度程序上的 Shutdown。

window.Dispatcher.InvokeShutdown();
Run Code Online (Sandbox Code Playgroud)

Microsoft Connect中报告了类似的问题