尝试从另一个进程调用 VSTO 加载项中的代码时出现转换问题

Casting issue when attempting to call code in a VSTO add-in from another process

我正在尝试调用 VSTO 加载项中的代码。

我在搜索中排名第一的是 MS Walkthrough Calling Code in an Application Level Add-in

  1. 我为 Outlook 创建了一个新的 VSTO 项目。
  2. 在这个项目中,我创建了以下 Note Attributes same in Walkthrough 并添加了 RequestComAddInAutomationService

  3. 然后我创建了一个 WPF 应用程序项目并添加了我的 VSTO 插件作为参考。

  4. 下面是发生的事情。请注意,如果我只是使用插件对象,我可以调用我的代码,但我无法转换接口。

我首先注意到的是 This blog uses different attributes.

对于任何登陆这里并在 C# 中寻找类似问题的人来说,有很多,this one being very similar 然而似乎非常特定于用户/计算机。

所以谁能帮我理解为什么我不能转换界面?

问题是接口没有为 COM 正确注册。一旦注册正确完成,演员就开始工作了。