简体   繁体   English

c# Outlook 插件 vsto 在使用 OL2010 PIA 时访问 OL2016 Interop

[英]c# outlook addin vsto access OL2016 Interop while working with OL2010 PIA

We have managed to build an outlook addin for 2010,2013 and 2016. We have created an OL2010 vsto project and fiddled with the .csproj file(1*).我们已经成功地为 2010、2013 和 2016 年构建了一个 Outlook 插件。我们创建了一个 OL2010 vsto 项目并处理了 .csproj 文件(1*)。 The problem is that few types were added in 2013/2016 and we can't access them.问题是 2013/2016 年添加的类型很少,我们无法访问它们。 We only want to access them if the respective OL version is used of course.当然,如果使用相应的 OL 版本,我们只想访问它们。

As far as i understand the whole thing: The Interop assemblies are delivered with the addin.据我了解整个事情:Interop 程序集随插件一起提供。 So its theoretically possible to inject some IL code or provide additional assemblies with the same namespace that provide those missing types.因此,理论上可以注入一些 IL 代码或提供具有相同命名空间的附加程序集,以提供那些缺少的类型。 Since those Interop assemblies are only COM Wrapper and the functionallity relies on unmanaged code which is provided by the installed Outlook version they should get loaded seamlessly when imported correctly.由于这些互操作程序集只是 COM 包装器,并且功能依赖于由已安装的 Outlook 版本提供的非托管代码,因此在正确导入时应该可以无缝加载。

Is that somehow feasible?这在某种程度上可行吗? What could go wrong if i try this/deploy the addin to the client?如果我尝试这个/将插件部署到客户端会出现什么问题?
How could i proceed to determine if i need to use a higher version Interop Type?我如何继续确定是否需要使用更高版本的互操作类型?
How can i load the higher Interop Type?如何加载更高的互操作类型?
How can i use it without conflicting existing types?如何在不与现有类型冲突的情况下使用它?
As i want Intellisense and static typing.因为我想要智能感知和静态类型。 I have to predefine those types and decorate them with Guid, CoClass, and TypeLibType.我必须预先定义这些类型并用 Guid、CoClass 和 TypeLibType 装饰它们。 Will that be enough?这样就够了吗?


(1*)(we changed the DebugInfoExeName and the OfficeVersion in the ProjectName.csproj file and built the respective installer with different virtual machines where the corresponding outlook versions are installed. Maybe there is an easier way? -> let me know!...sadly we can't use addin-express because of some reasons. (1*)(我们更改了 ProjectName.csproj 文件中的 DebugInfoExeName 和 OfficeVersion,并使用安装了相应 Outlook 版本的不同虚拟机构建了各自的安装程序。也许有更简单的方法?-> 让我知道!.. . 遗憾的是,由于某些原因我们不能使用 addin-express。

I would preferably not use the complete OL 2016 Interop Assemblies since it is throwing exceptions when used from other Threads than the main threads.我最好不要使用完整的 OL 2016 互操作程序集,因为它在从主线程以外的其他线程使用时会抛出异常。 And we have some synchronization code which has to be run in the background.我们有一些必须在后台运行的同步代码。

Thank you for any answers!感谢您提供任何答案!

"Creating interops manually: In Visual Studio, just add a COM reference to an application of the Office 2000 suite to the project. This automatically creates the interop you need. But it is the point where your problem begins: a great number of classes and events are inaccessible, because a number of identical bugs in Office type libraries make Studio create the interop that will not work for you. You can disassemble the interop, make unavailable classes and events public, and recompile it (ildasm.exe and ilasm.exe). This is exactly the way Add-in Express version-neutral interops were created." “手动创建互操作:在 Visual Studio 中,只需将一个对 Office 2000 套件应用程序的 COM 引用添加到项目中。这会自动创建您需要的互操作。但这正是您的问题开始的地方:大量的类和事件无法访问,因为 Office 类型库中的许多相同错误使 Studio 创建了对您不起作用的互操作。您可以反汇编互操作,公开不可用的类和事件,然后重新编译它(ildasm.exe 和 ilasm.exe )。这正是 Add-in Express 版本中立互操作的创建方式。” source: https://social.msdn.microsoft.com/Forums/en-US/a95cd4e3-e619-4846-be2a-ce4c235ff457/is-it-possible-to-use-the-microsoftofficeinteropoutlook-that-comes-from-office-2010-with-all?forum=outlookdev来源: https : //social.msdn.microsoft.com/Forums/en-US/a95cd4e3-e619-4846-be2a-ce4c235ff457/is-it-possible-to-use-the-microsoftofficeinteropoutlook-that-c​​omes-from- office-2010-with-all?forum=outlookdev

EDIT编辑

Checkout this project https://github.com/netoffice/NetOffice-NuGet签出这个项目https://github.com/netoffice/NetOffice-NuGet
It contains version neutral interop assemblies though the structure and namespaces dont match... But still could be useful.尽管结构和命名空间不匹配,但它包含版本中立的互操作程序集......但仍然可能有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM