【问题标题】:Excel VSTO project not loading after upgrading from Office 2013 to Office 2016从 Office 2013 升级到 Office 2016 后 Excel VSTO 项目未加载
【发布时间】:2017-01-06 03:46:58
【问题描述】:

使用 VS 2013(安装了 Office 2016)加载项目时出现以下错误

无法创建项目,因为与此关联的应用程序 此计算机上未安装项目类型。您必须安装 与此项目关联的 Microsoft Office 应用程序 输入。

C# 项目最初是使用 VS 2013 和 Office 2013 创建为 Excel 工作簿,运行时为“Visual Studio 2010 Tools for Office Runtime”。 .Net Framework 也没有改变。根据https://msdn.microsoft.com/en-us/library/bb772080.aspx,我觉得一切都很好

当我查看 .csproj 文件时,我发现以下对 Office Dll、Office 版本和 ProjectProperties 部分的引用指向 C:\Program Files\Microsoft Office\Office15\Excel.exe,它在升级到 Office 2016。

我需要在 .csproj 文件中手动修复哪些内容才能加载项目?

 <ItemGroup>
    <Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Private>False</Private>
    </Reference>
    <Reference Include="Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Vbe.Interop, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
      <Private>False</Private>
      <EmbedInteropTypes>true</EmbedInteropTypes>
    </Reference>
  </ItemGroup>

.....

<ProjectProperties HostName="Workbook.xlsx" HostPackage="{3F2B7691-D1D1-402F-9370-2704A737CF60}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="XLS" Language="CS" TemplatesPath="VSTOTemplates" DebugInfoExeName="C:\Program Files\Microsoft Office\Office15\Excel.exe" DebugInfoCommandLine="/x &quot;[$OUTPUT]Workbook.xlsx&quot;" />

【问题讨论】:

  • 我花了一些时间研究类似的问题,但不完全是与 Office 2013 到 Office 2016 升级相关的问题。但是,在装有 Office 2013 的机器上创建的 VSTO 项目真的只能在装有 Office 2013 的机器上工作(用于开发)吗?我的 Visual Studio 版本一直是“VS Premium 2013 Update 5”

标签: c# excel visual-studio-2013 vsto office-2016


【解决方案1】:

我在 Visual Studio 2015 中解决了类似的问题,也许这会有所帮助。

我在 Visual Studio 外部手动编辑了文件 .csproj,将 ProjectProperties 元素中的属性 OfficeVersion="15.0" 更改为 OfficeVersion="14.0"(是的!降级!)

然后,当我在 Visual Studio 中打开解决方案时,该项目被标记为 (需要迁移),然后当我尝试重新加载项目时,Visual Studio 要求迁移项目,然后执行所有工作。

注意首先确保您能够创建一个新项目“Excel 2013 and 2016 VSTO Workbook”,如果不能尝试更新 Excel 并验证是否启用了 VSTO 加载项

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-04
    • 1970-01-01
    • 2010-11-11
    相关资源
    最近更新 更多