在我从应用程序以模式 window 打开此任务后,Outlook 在模式 window 中打开任务

Outlook opens the task in a modal window after I opened this task in a modal window from the application

我使用 Display(true) 方法(模态 window)从我的应用程序打开任务。关闭任务后,Outlook 开始以模式 window 打开此任务。但是当我关闭我的应用程序时,Outlook 开始以正常状态打开此任务 window。为什么会这样?如何解决这个问题?

尝试关闭并等待在 finally 语句中明确。

email.Close();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

所有 Outlook 加载项都应在不再需要时系统地释放对 Outlook 对象的引用。未能系统地释放对 Outlook 对象的引用可能会导致 Microsoft Office Outlook 无法正常关闭。

我建议改用 Marshal class 的 ReleaseComObject 方法。两次调用 GC 方法会影响 .Net 应用程序的性能并需要一些时间才能完成。因此,使用完 Outlook 对象后,使用 System.Runtime.InteropServices.Marshal.ReleaseComObject 释放它。然后在 Visual Basic 中将变量设置为 Nothing(在 C# 中为 null)以释放对该对象的引用。

您可以在 MSDN 的 Systematically Releasing Objects 文章中阅读更多相关信息。