简体   繁体   English

VSTO 2012:向后兼容性

[英]VSTO 2012: backward compatibility

Since lately the Visual Studio Tools For Office 2012 (VSTO 2012) are available for download . 最近, Visual Studio Tools For Office 2012 (VSTO 2012) 可供下载

Can this new version still used for developing Add-In solutions for older Office versions (2007,2010)? 这个新版本是否仍可用于为旧版Office(2007,2010)开发插件解决方案? Are there any advantages over VSTO 4.0 (besides Office 2013 support) 是否比VSTO 4.0有任何优势(除了Office 2013支持)

Yes, it can. 是的,它可以。 I'm using VS2012 for an Excel 2007 project and it works fine. 我正在使用VS2012进行Excel 2007项目,它运行正常。

The trick is to change the debug path in your project file so that VS uses the older version of the Office app your plugin is for. 诀窍是更改项目文件中的调试路径,以便VS使用插件所用的旧版Office应用程序。

  1. Create your VSTO project (let VS create the project for Office 2010) 创建您的VSTO项目(让VS为Office 2010创建项目)
  2. Edit the project file and find the <ProjectProperties> with a HostName attribute. 编辑项目文件并找到具有HostName属性的<ProjectProperties> It will be a child element of a <VisualStudio> element. 它将是<VisualStudio>元素的子元素。
  3. Change the DebuginfoExeName attribute value of the <ProjectProperties> attribute to be the path to the older version of the Office application .exe file <ProjectProperties>属性的DebuginfoExeName属性值更改为旧版Office应用程序.exe文件的路径
  4. Save your project 保存您的项目

Now when you go to debug your app it should launch the older version of your Office app and attach to that process to load your VSTO. 现在,当您去调试应用程序时,它应该启动旧版Office应用程序并附加到该进程以加载您的VSTO。

In my project, the new <ProjectProperties> element looks like this for Excel 2007: 在我的项目中,新的<ProjectProperties>元素对于Excel 2007是这样的:

<ProjectProperties
    HostName="Excel"
    HostPackage="{20A848B8-E01F-4801-962E-25DB0FF57389}" OfficeVersion="14.0"
    VstxVersion="4.0"
    ApplicationType="Excel"
    Language="cs"
    TemplatesPath=""
    DebugInfoExeName="#Software\Microsoft\Office\12.0\Excel\InstallRoot\Path#excel.exe"
    AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />

Deployment also works fine. 部署也很好。 I deploy my add-in via ClickOnce and it is added to Excel 2007 clients without any additional changes. 我通过ClickOnce部署我的加载项,并将其添加到Excel 2007客户端,而无需任何其他更改。

As far i know you can deploy your solution to previous version office. 据我所知,您可以将解决方案部署到以前的版本办公室。 I once developed an add-in for ppt 2013 and it worked fine in ppt 2010. Note that The API for the new VSTO has several additional features and last time i only used existing features, but not the new ones. 我曾经为2013年ppt开发了一个加载项,它在2010年ppt上运行良好。请注意,新VSTO的API有几个附加功能,上次我只使用现有功能,但不是新功能。

I've never tested this, but i think if you use new event handler that only works in 2013, when you deploy it in 2010 it simply does nothing / doesn't work. 我从来没有测试过这个,但我认为如果你使用新的事件处理程序只能在2013年运行,当你在2010年部署它时,它什么都不做/不起作用。

As i mentioned, the obvious advantage of new VSTO is more features available, for example in ppt 2013, it has event handler when the users do dragging, you should checked them by yourselves. 正如我所提到的,新VSTO的明显优势是可用的功能更多,例如在2013年ppt中,当用户拖动它时它有事件处理程序,你应该自己检查它们。 If your solution doesn't need these new features, you can develop it in the previous version of VSTO to make sure the backward compatibility. 如果您的解决方案不需要这些新功能,则可以在以前版本的VSTO中进行开发,以确保向后兼容性。

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

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