C# 部署/安装 Outlook 插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9172970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deploying/Installing an outlook addin
提问by Simon
I am trying to install my Outlook Addin on client computers.
我正在尝试在客户端计算机上安装我的 Outlook 插件。
Unfortuantely, the Add-in can never be 'Enabled' it is always shown in the Disabled add-in section.
不幸的是,加载项永远无法“启用”,它始终显示在“禁用加载项”部分。
Is there a simple, step by step guide on how to create the correct setup application and install an outlook addin?
是否有关于如何创建正确的安装应用程序和安装 Outlook 插件的简单分步指南?
EDIT:
编辑:
Ok so ive gone back to basics, but i still cant get it to install correctly.
好的,我回到了基础,但我仍然无法正确安装它。
I create a new Outlook Addin using VS2010 project wizard.
我使用 VS2010 项目向导创建了一个新的 Outlook 插件。
It generates files etc, and then i change my code like so:
它生成文件等,然后我像这样更改我的代码:
namespace OutlookAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
MessageBox.Show("Worked");
}
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
}
If i install this one, i get the same error message:
如果我安装这个,我会收到相同的错误消息:
Not Loaded. The Managed Add-in Loader failed to initialize.
When installing the Add-in I ensure the registry keys are created:
安装插件时,我确保创建了注册表项:


I have also added the .manifestfile and the .vstofile to the Setup project.
我还将.manifest文件和.vsto文件添加到安装项目中。
Still stumped!
还是难住了!
采纳答案by woodykiddy
I think this tutorial might be useful for your reference.
我认为本教程可能对您的参考有用。
http://msdn.microsoft.com/en-us/library/ff937654.aspx
http://msdn.microsoft.com/en-us/library/ff937654.aspx
Also, there are a few other things that you might want to check out. First, see if you have any COM exceptions thrown when you start up Outlook Addin. Normally addin will not be disabled automatically if it throws errors on startup. And you also want to have a look at loadBehaviorregistry key and see what values you got in there.
此外,您可能还想查看其他一些内容。首先,查看在启动 Outlook Addin 时是否抛出了任何 COM 异常。如果插件在启动时抛出错误,通常不会自动禁用它。而且您还想查看loadBehavior注册表项并查看您在那里获得的值。
For details of LoadBehavior reg key, please refer to: http://msdn.microsoft.com/en-us/library/bb386106(VS.100).aspx
LoadBehavior reg key 的详细信息,请参考:http: //msdn.microsoft.com/en-us/library/bb386106(VS.100) .aspx
回答by Simon
With the help of woodykiddy, I eventually managed to build the installer and successfully install! Anyone coming here should visit the link provided in his post.
在woodykiddy的帮助下,我最终成功构建了安装程序并成功安装!任何来到这里的人都应该访问他帖子中提供的链接。
I just wanted to elaborate on the general process I followed to get it to work.
我只是想详细说明我为使其工作而遵循的一般过程。
Firstly, the regisrty entries are important, especially the Manifest and LoadBehavior keys. Make sure it points to the correct installation location. You also need to ensure the correct runtimes are installed, e.g. VSTO 2010 for Office runtime, and Office Primary Interop Assembly (if required).
首先,注册表项很重要,尤其是 Manifest 和 LoadBehavior 键。确保它指向正确的安装位置。您还需要确保安装了正确的运行时,例如用于 Office 运行时的 VSTO 2010 和 Office 主互操作程序集(如果需要)。
Also, it was important to manually add the *.vsto and *.dll.manifest created in the \Release\ folder of you Addin, to the Setup Project.
此外,将在 Addin 的 \Release\ 文件夹中创建的 *.vsto 和 *.dll.manifest 手动添加到安装项目中也很重要。
I found that the Register for COM Interopneed NOTbe checked, whilst the Make Assembly COM Visbleproperty in the Applications Properties MUSTbe checked.
我发现,Register for COM Interop需要不进行检查,而Make Assembly COM Visble在属性的应用性能必须进行检查。
And finally, ensure any Microsoft *.dll's not containing *.Utilities.dllwere Excludedfrom the Setup project.
最后,确保在任何微软*.dll的不含*.Utilities.dll分别Excluded从安装项目。
Sorry one last thing, when installing, install for "Just Me" to a writable folder e.g. [LocalAppDataPath]. There are also other caveats when users do not have adminstrator priveldges.
抱歉最后一件事,安装时,将“Just Me”安装到可写文件夹,例如[LocalAppDataPath]. 当用户没有管理员权限时,还有其他注意事项。
回答by Ole K
Here is a short check list on how to troubleshoot possible issues with Outlook Addin
这是有关如何解决 Outlook Addin 可能出现的问题的简短清单
(of course not everything is covered)
(当然不是所有的都包括在内)
Is the plugin properly registered on the client machines?
插件是否在客户端机器上正确注册?
Check registry entries (HKLM\Software\Microsoft\Office\Outlook\Addins) and regasm.exe
检查注册表项 (HKLM\Software\Microsoft\Office\Outlook\Addins) 和 regasm.exe
Also make sure Make Assembly COM Visblelocated in Project Properties -> Assembly Informationis checked
还要确保Make Assembly COM Visble位于Project Properties -> Assembly Information被选中
Have you deployed all dependencies together with the plugin assembly?
您是否已将所有依赖项与插件程序集一起部署?
Its important esspecially when you build your own setup (either through WIX or installshield, ...).
当您构建自己的设置(通过 WIX 或 installshield,...)时,它尤其重要。
Is there an error in the plugin while starting Outlook?
启动 Outlook 时插件中是否有错误?
Check event viewer for Outlook errors and warnings
检查事件查看器是否有 Outlook 错误和警告
It can also "disappears" when version number / GUID of the plugin assembly has changed or there is a conflict
当插件程序集的版本号/GUID 已更改或存在冲突时,它也可能“消失”
Try to fix it by deleting the CLSID keys in registry
尝试通过删除注册表中的 CLSID 键来修复它
REM 64bit entry in HKEY_CLASSES_ROOT
reg delete HKCR\CLSID\{GUID} /f
REM 32bit entry in HKEY_CLASSES_ROOT
HKCR\Wow6432Node\CLSID\{GUID}
and re-register the assembly through regasm.exe
并通过 regasm.exe 重新注册程序集

