VSTO Outlook 加载项问题

发布于 2024-08-09 20:49:39 字数 2165 浏览 3 评论 0原文

我创建的 Outlook 加载项遇到问题。不知何故,Outlook 无法正常关闭。我看过所有关于使用 ReleaseComObject 等的帖子。

====更新====

我再次尝试了整个过程,在新的解决方案中创建了一个新的空项目,现在,关闭 Outlook 一段时间后,Visual Studio 中向我显示以下错误消息。不知何故,我认为我必须在以前的解决方案中禁用获得该异常。我还不知道这意味着什么,但我会去狩猎。也许这会给这个问题带来一些启发?效果仍然相同:Outlook 不会关闭。

检测到 ContextSwitch 死锁 消息: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
    }
}

I am running into problems with an Outlook Add In I created. Somehow Outlook doesn't shut down properly. I've seen all the postings about using ReleaseComObject and such.

==== UPDATE ====

I tried the whole thing again, creating a new empty project in a new solution and now, after some time after shutting down Outlook the following Error message is presented to me in Visual Studio. Somehow I think I must have disabled getting that exception in the previous solutions. I don't know what it means (yet) but I will go for a hunt. Maybe this will shine some light on the issue? The effect is still the same: Outlook doesn't shut down.

ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x55cdd8 to COM context 0x55cf48 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

Also when I try to remove the add in when not in safe mode (e.g. it has been loaded) Oulook locks up when hitting the remove button in the safe center). Guess that's the same cause though.

===== END OF UPDATE ====

To debug what's going on I did the simplest thing imaginable:

1) Using Visual Studio 2008 I created a new Outlook 2007 Add In Project

2) I started the debugger with the new add in.

3) After some time I close down Outlook, expecting it to properly close down.

It doesn't. The code does reach the generated ThisAddIn_Shutdown method. But, Outlook doesn't shut down.

To make sure I'm not completely insane, I downloaded, compiled and tried the extensive example found at http://code.msdn.microsoft.com/ContosoAutoOBA. Using this add in has the same effect: Outlook doesn't close down.

I tried this with no other add ins available: that doesn't make a difference.

Just for the record, below you find the generated code.

I'm using Windows 7, Visual Studio 2008, Office 2007, all updates are installed.

Is there someone that can shine a light on this. You help is greatly appreciated.

Thanks,

Bart

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
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜柠檬 2024-08-16 20:49:39

问题似乎出在 Microsoft CRM 加载项上。我之前禁用了它(实际上禁用了所有 Outlook 插件),但显然这还不够。实际上,将其从我的计算机中删除就解决了问题。

似乎有 Microsoft CRM 插件的更新 7 汇总,但它拒绝安装在我的计算机上。唉,至少我可以继续使用我自己的 Outlook 插件。从现在起我将在屏幕上发布它作为我的新 CRM 系统。

It appears that the Microsoft CRM Add In is the problem. I disabled it earlier (in fact disabled all Outlook plug ins), but apparently that isn't enough. Actually removing it from my computer solved the problem.

There seems to be a update 7 roll up for the Microsoft CRM plugin, but it refuses to install on my machine. Alas, at least I can continue with my own Outlook plug in. I will keep a post it on my screen from now own as my new CRM system.

捶死心动 2024-08-16 20:49:39

啊,VSTO 开发的日子!

从内存中 - 要解决此问题:

  1. 关闭所有正在运行的 Outlook 实例(任务管理器、结束进程)
  2. 使用 VS.NET 中的调试按钮启动应用程序

从内存中;当已经有一个实例正在运行时,它会播放一点。

Ah the days of VSTO development!

From memory - to fix this:

  1. Close all instances of Outlook running (Task Manager, End Process)
  2. Start the application by using the debug button in VS.NET

From memory; it plays up a bit when there was already an instance running.

等待圉鍢 2024-08-16 20:49:39

首先。
您运行的是哪个版本的 Office Service Pack。 SP2 中有大量修复程序可以帮助关闭。

你是说如果你没有安装插件outlook会正常关闭吗?
我想知道您是否安装了其他 inder 信任中心。 ?

First up.
What version of the office service pack are you running. There are loads of fixes in SP2 to help shutdown.

Are you saying that if you dont have the addin installed outlook shuts down ok ?
As I wonder if you have any other installed inder trust center. ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文