Visual Studio 无法在新计算机上打开 VSTO

Visual Studio cant open VSTO on new Computer

我有一个包含 4 个项目的解决方案。 其中 2 个是 VSTO 项目(在 Win7 for Office 2010 / .net4.5 上创建)(Excel/Powerpoint) 其中 2 个只是普通的 VB.Net 项目。

我有一台 PC 运行 Windows 10 和 Office 2013,可以很好地打开所有项目。

现在我有了新的 Surface book。 运行 win 10 和 Office 2016 出于其他兼容性原因,我还安装了一个 Office 2010 版本。

不过我在Surface book上只能打开普通的Peojects。 无法打开 2 个 VSTO 项目。尝试加载它们时(或单击安装缺少的功能)我收到此消息:

我已经检查了所有参考资料。 (通过手动搜索 .dll 的路径)

在 Surface book 上的安装顺序是:

  1. Office 2010

  2. Office 2016

  3. Visual Studio 社区 2015

  4. Visual Studio 2015 年 VSTO

  5. Visual Studio Office 运行时工具 2010

我真的不明白为什么我无法打开项目:(

编辑:看来 .net 4.5 是罪魁祸首。

表面上,当我创建一个 Excel 2010 插件时。它是针对 4.5.2

创建的

一旦我将其更改为 4.5,它会尝试 "one way upgrade" 并且不再能够打开项目。

您需要安装 http://aka.ms/officedevtoolsforvs2015

请记住,VSTO 允许开发特定于版本的加载项。有关详细信息,请参阅 Running Solutions in Different Versions of Microsoft Office

在 .vbproj 文件中有两行似乎很关键:

Visual Studio 2015:

第二行:

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props')" />

再往下的某个地方:

<!-- Include additional build rules for an Office application add-in. -->
  <Import Project="$(VSToolsPath)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />

有趣的事实:在 Visual Studio 2017 年,一切都加载得很好 :thumbsup: