用于 Outlook 的 VSTO 插件将无法工作

VSTO Addin for Outlook won't work

我看过很多解决这个问题的帖子和网站。我已经尝试了我找到的所有解决方案,但其中 none 有效(几天来我一直在努力解决这个问题)。我看到很多帖子都有完全相同的问题,但解决方案对我不起作用或不适用。话虽如此...

我有一个用于 Outlook 2007 的 add-in,旨在将文本添加到电子邮件的标题和 body。它是为所有使用 .msi 文件的用户安装的。我去年部署了一个旧版本,运行良好。我创建的新版本只有一些小的 input/output 变化,没有什么大的变化。这个新版本在我的开发计算机上完美运行,无论是从 Visual Studio 调试还是从实际安装。但是,我无法让它在 non-development 计算机上运行。下面是程序和目标机的详细信息(开发机和目标机除了目标机没有Visual Studio外其他信息都是一样的):

-Using Visual Studio Professional 2013
-Written in Visual Basic
-Target Framework is .NET 4.0
-The add-in is only run once the "send" button on an email is clicked.
-Outlook version is Outlook 2007
-Operating system is Windows 7 Enterprise SP1 32-bit

问题是 add-in 无法在目标计算机上加载(是的,我知道,无数其他人也遇到过同样的问题)。正如我之前所说,它在我的计算机上的调试和安装版本都运行良好。这让我觉得另一台计算机丢失了一些东西,所以我尝试在目标计算机上安装 .NET 4.0 框架,但它告诉我它已经安装了。我 运行 尽我所能使它正常工作,但无济于事。这是它的行为方式:

-Installs fine with no errors.
-HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Office/Outlook/Addins/EmailMarkTool/LoadBehavior = 3 after installation.
-VSTO_LOGALERTS = 1
-VSTO_SUPPRESSDISPLAYALERTS = 0
-Outlook opens with no apparent errors.
-LoadBehavior = 0 immediately after Outlook is opened.
-Shows up in the Add-ins under "Inactive Application Add-ins."
-Never shows up under "Disabled Add-ins."
-In the "COM Add-Ins" dialog where I can check which add-ins to use, it shows the correct directory and the Load Behavior is "Unloaded."
-The add-in can be checked. When I click "OK" I don't get any errors. When I go back to the Add-ins, it is unchecked and "Unloaded" again.
-Setting the LoadBehavior to 3 doesn't help because it goes back to 0 as soon as Outlook is started again.
-I inserted a try-catch block into the New() function of the add-in that has a MsgBox pop-up and a Throw.
-I get absolutely no errors anywhere.
-No log file is generated.

我试过多次卸载、重建和重新安装,结果都一样。我只是不明白为什么它可以在我的开发计算机上运行,​​但不能在目标计算机上运行。感谢您阅读所有这些。我知道很多,但我需要了解详细信息。在此先感谢您的任何输入!

[更新]:我刚刚创建了一个 b运行d new minimal add-in 只是为了测试它是否有效但得到了相同的结果。

您遇到的 loadbehaviour 关键问题很奇怪。虽然我认为这可能不是您的解决方案,但它可能是,所以值得一试。

目标计算机需要安装 Office 运行时的 VSTO 工具。 您可以下载这些工具如下link - https://www.microsoft.com/en-GB/download/details.aspx?id=48217

我找到问题了!

这个问题可能是 Outlook 2007 独有的。事实证明,Microsoft Office 2007 SP1 和 SP2 有一个错误,导致它无法使用 运行 VSTO 插件。 Microsoft 发布了修复此问题的修补程序 (https://support.microsoft.com/en-us/kb/976477). This was added in to the release of Microsoft Office SP3. However, to activate the fix, a new registry flag must be created but that isn't automatically done with the fix, making the fix useless until you manually activate it (instructions and download here)。所以...

要在 Outlook 2007 中启用 VSTO 插件,您必须向此注册表添加一个子项:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office.0\Common\General\ 并添加一个 DWORD "EnableLocalMachineVSTO" 并将值设置为 1.

我这样做了,重新启动了计算机,第 23 次安装了我的插件,它安装 运行 完美!不过,我不确定以前的版本是如何工作的。我们的系统管理员可能删除了该子项以在某个时候加强安全性。