【发布时间】:2010-12-10 07:55:18
【问题描述】:
我在创建 Outlook 插件时遇到问题。不知何故,Outlook 无法正常关闭。我看过所有关于使用 ReleaseComObject 等的帖子。
==== 更新 ====
我再次尝试了整个过程,在新解决方案中创建了一个新的空项目,现在,在关闭 Outlook 一段时间后,Visual Studio 中向我显示了以下错误消息。不知何故,我认为我必须在以前的解决方案中禁用了该异常。我不知道这意味着什么(还),但我会去打猎。也许这会对这个问题有所启发?效果还是一样:Outlook 没有关闭。
检测到 ContextSwitchDeadlock 消息:CLR 在 60 秒内无法从 COM 上下文 0x55cdd8 转换到 COM 上下文 0x55cf48。拥有目标上下文/单元的线程很可能要么进行非泵送等待,要么处理非常长时间运行的操作而不泵送 Windows 消息。这种情况通常会对性能产生负面影响,甚至可能导致应用程序变得无响应或内存使用量随着时间的推移不断累积。为避免此问题,所有单线程单元 (STA) 线程都应使用泵送等待原语(例如 CoWaitForMultipleHandles)并在长时间运行的操作期间定期泵送消息。
此外,当我在未处于安全模式时(例如已加载)尝试删除插件时,Oulook 在按下安全中心的删除按钮时会锁定)。猜猜这也是同样的原因。
===== 更新结束 ====
为了调试正在发生的事情,我做了可以想象的最简单的事情:
1) 我使用 Visual Studio 2008 创建了一个新的 Outlook 2007 插件项目
2) 我使用新插件启动了调试器。
3) 一段时间后,我关闭了 Outlook,希望它能正常关闭。
它没有。代码确实到达了生成的 ThisAddIn_Shutdown 方法。但是,Outlook 不会关闭。
为了确保我没有完全发疯,我下载、编译并尝试了在http://code.msdn.microsoft.com/ContosoAutoOBA 找到的广泛示例。使用此插件具有相同的效果:Outlook 不会关闭。
我在没有其他可用插件的情况下尝试了这个:这没有任何区别。
仅作记录,您可以在下面找到生成的代码。
我使用的是 Windows 7、Visual Studio 2008、Office 2007,所有更新都已安装。
是否有某人可以对此有所启发。非常感谢您的帮助。
谢谢,
巴特
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn3
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
【问题讨论】:
-
您是否安装了任何其他插件(可能在不知不觉中,请查看确定)?