简体   繁体   English

.NET项目中的Office主互操作程序集的多个版本

[英]Multiple versions of Office Primary Interop Assemblies in .NET project

I'm using Office Primary Interop Assemblies to control PowerPoint from my WPF app. 我正在使用Office Primary Interop程序集从WPF应用程序控制PowerPoint。 Currently I'm using PIA v14 in my project and it works with both Office 2010 and Office 2013 without problems. 当前,我在项目中使用的是PIA v14,它可以与Office 2010和Office 2013一起正常使用。 But I need to add support also for Office 2007 (when I tested my app on computer with Office 2007, it didn't work). 但是我还需要增加对Office 2007的支持(当我在装有Office 2007的计算机上测试我的应用程序时,它不起作用)。

So, my question is: Should I change my referenced PIA in project to the v12 (to support Office 2007/2010/2013) or it is possible to add both v12 and v14 (maybe also v15) PIAs to the project and dynamically loads correct version of assemblies during app start based on Office version installed on target computer? 因此,我的问题是:我应该将项目中引用的PIA更改为v12(以支持Office 2007/2010/2013),还是可以将v12和v14(也许还有v15)PIA添加到项目中并动态加载正确应用程序启动过程中的程序集版本是否基于目标计算机上安装的Office版本? Also, is there some compatibility risks, if I will use PIA v12 on all Office versions (2007/2010/2013)? 此外,如果我将在所有Office版本(2007/2010/2013)上使用PIA v12,是否存在兼容性风险?

There is a simple solution for this, Use one of the Office Interop wrapper assemblies. 为此,有一个简单的解决方案,即使用Office Interop包装程序组件之一。 These wrapper amssemblies use late binding to support the feature of specific version of Office. 这些包装程序组合使用后期绑定来支持Office特定版本的功能。 I have used NetOffice and I would recommend you to use this. 我曾经使用过NetOffice ,建议您使用它。

Features provided by NetOffice NetOffice提供的功能

  • Office integration without version limitations 没有版本限制的Office集成
  • All features of the Office versions 2000, 2002, 2003, 2007, 2010, 2013 are included 包含Office版本2000、2002、2003、2007、2010、2013的所有功能
  • Syntactically and semantically identical to the Microsoft Interop Assemblies 语法和语义上与Microsoft Interop程序集相同
  • No training if you already know the Office object model, use your existing PIA code 如果您已经知道Office对象模型,则无需培训,请使用现有的PIA代码
  • Usable with .NET version 2.0 or higher 可与.NET 2.0或更高版本一起使用
  • No dependencies, no interop assemblies, no need for VSTO 没有依赖关系,没有互操作程序集,不需要VSTO

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

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