Multiple versions of Office Primary Interop Assemblies in .NET project

喜夏-厌秋 提交于 2020-01-25 10:59:05

问题


I'm using Office Primary Interop Assemblies to control PowerPoint from my WPF app. Currently I'm using PIA v14 in my project and it works with both Office 2010 and Office 2013 without problems. But I need to add support also for Office 2007 (when I tested my app on computer with Office 2007, it didn't work).

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? Also, is there some compatibility risks, if I will use PIA v12 on all Office versions (2007/2010/2013)?


回答1:


There is a simple solution for this, Use one of the Office Interop wrapper assemblies. These wrapper amssemblies use late binding to support the feature of specific version of Office. I have used NetOffice and I would recommend you to use this.

Features provided by NetOffice

  • Office integration without version limitations
  • All features of the Office versions 2000, 2002, 2003, 2007, 2010, 2013 are included
  • Syntactically and semantically identical to the Microsoft Interop Assemblies
  • No training if you already know the Office object model, use your existing PIA code
  • Usable with .NET version 2.0 or higher
  • No dependencies, no interop assemblies, no need for VSTO


来源:https://stackoverflow.com/questions/30047112/multiple-versions-of-office-primary-interop-assemblies-in-net-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!