【问题标题】:Outlook 2003 add-in - Getting COM exception on application shutdown after creating WPF windowOutlook 2003 加载项 - 在创建 WPF 窗口后关闭应用程序时出现 COM 异常
【发布时间】:2011-01-31 20:05:31
【问题描述】:

我正在开发 Outlook 2003 插件。到目前为止,我只使用 winforms 来显示一个表单,但今天我添加了一个 WPF 窗口来处理更复杂的内容。由于 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: 

最好的问候,
奥利弗·哈纳皮

【问题讨论】:

    标签: .net exception com outlook vsto


    【解决方案1】:

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

    window.Dispatcher.InvokeShutdown();
    

    Microsoft Connect中报告了类似的问题

    【讨论】:

    • 不错。这对我很有用。更新我给出的另一个答案(关于在新线程中启动 WPF 窗口)以包含此内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 2012-04-22
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多