Outlook的COM插件已安装但未在Outlook中加载

4
我使用Visual Studio 2010创建了一个Outlook插件,安装很顺利,按照我指定的在Program Files(x86)中创建了适当的注册表键和文件夹,并在添加/删除程序中显示。但是,当我启动Outlook 2010时,它没有显示出来,而且当我检查COM Add-ins时,它也不在列表中。我在VS中创建了设置,并像往常一样将主项目的输出添加到文件系统中,还包括了.vsto文件。请问有什么建议吗?

可能不是你的问题,但是:要加载在HKEY_LOCAL_MACHINE下注册的插件,计算机必须安装热修复程序包976477。有关更多信息,请参见http://go.microsoft.com/fwlink/?LinkId=184923。 - David Brabant
谢谢您的建议,但我忘了提到我正在运行Windows 7 x64和Office 2010 x64,而HotFix仅适用于Office 2007。我已经将注册表放在了正确的Hive Wow6432Node中。 - James
2个回答

4

谢谢SilverNinja。我已经在注册表中进行了更改,应用程序安装正常,但未添加到Outlook的COMAddin中。然而,当我转到安装目录并双击MyOutlookAddin.vsto时,它可以正常安装。请问有什么建议吗? - James
所以我创建了MSI并运行它,但它仍将注册表放在Wow6432Node中,尽管Office和Windows都是x64。然后我导出了MyOutlookAddin hive并编辑它,使其指向HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook\Addins。打开Outlook,猜猜看....插件出现了。下一个问题是,如何在Visual Studio中将注册表键添加到普通和Wow6432Node hive中? - James
@James - 你应该标记这个问题已回答,并创建一个新问题进行跟进,同时链接到这个原始帖子以供参考。 - SliverNinja - MSFT
会的。谢谢SilverNinja。下一个问题:https://dev59.com/PGrWa4cB1Zd3GeqP6w8W - James

3
您可以通过这个难以找到的技巧在HKLM上为所有用户运行您的插件,而无需使用ClickOnce:

在您的VSTO清单路径值后面放置一个管道和“vstolocal”标志,如下所示:

HKLM \ Software \ Microsoft \ Office \ Outlook \ Addins \ MyVSTOAddIn
清单=“C:\ Program Files \ Publisher \ MyVSTOAddIn \ MyVSTOAddIn.vsto | vstolocal”

(参见:http://blogs.msdn.com/b/vsto/archive/2010/03/08/deploying-your-vsto-add-ins-to-all-users-saurabh-bhatia.aspx)

并设置EnableLocalMachineVSTO标志,如下所示:

HKLM \ Software \ Microsoft \ Office \ 14.0 \ Common \ General
(DWORD) EnableLocalMachineVSTO = 1

(参见:http://social.msdn.microsoft.com/Forums/vstudio/en-US/e724cdcb-ccad-4d9f-826a-65a6816409f9/vsto-alluser-addin-fails-to-load-on-several-clients)

此外,如果您要安装64位版本的Windows,则必须在另一个位置使用两个值启用本地机器安装:

HKLM64 \ SOFTWARE \ Microsoft \ VSTO Runtime Setup \ v4
(DWORD) EnableVSTOLocalUNC = 1
(DWORD) EnableLocalMachineVSTO = 1

(参见:http://support.microsoft.com/kb/2022442)

无需SideBySide、PromptingLevel、VSTO\Security\Inclusion和Active Setup\Installed Components“StubPath”!只需安装和运行。

添加于2013年10月3日...

还有一点需要注意:在Win64中,Outlook 2010会进一步难以信任VSTO插件,除非您使用真实的代码签名PFX对其进行签名,并将证书放置在用户计算机的 Trusted Publishers 存储中。我编写了这个命令行实用程序,并将PFX嵌入到可执行文件中,以使证书成为安装过程的一部分。要访问本地计算机的Trusted Publishers存储,必须以管理员身份运行此程序:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.IO;

namespace TrustCert
{
    class Program
    {
        static void Main(string[] args)
        {
            string msg = "";
            try
            {
                byte[] pfx;
                var assembly = typeof(Program).Assembly;
                string pfxName = "";
                foreach (string mr in assembly.GetManifestResourceNames())
                {
                    if (mr.Contains("MyPfxName"))
                    {
                        pfxName = mr;
                        break;
                    }
                }
                using (var stream = assembly.GetManifestResourceStream(pfxName))
                {
                    pfx = new byte[stream.Length];
                    stream.Read(pfx, 0, pfx.Length);
                }
                X509Certificate2 cert = new X509Certificate2(pfx, "pfxPassword");
                X509Store store = new X509Store(StoreName.TrustedPublisher
                    , StoreLocation.LocalMachine);
                store.Open(OpenFlags.ReadWrite);
                store.Add(cert);
                store.Close();
                msg = "Certificate installed";
            }
            catch (Exception e)
            {
                msg = e.ToString();
            }
            Console.WriteLine(msg);
        }
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接