VSTO Tools: Office 2010 to 2013 upgrade

jpsfs

I'm working on a VSTO tools project for Excel. I'm now in the process of upgrading my machine. My "old" laptop was running Windows 7 x64 with Office 2010 and Visual Studio 2012. My new machine has Windows 8 x64 with Office 2013 and Visual Studio 2012.

When opening my solution on VS2012, in the new machine, it gives me an error loading the project:

Cannot create the project because the application associated with this project type is not installed on this computer. You must install the Microsoft Office application that is associated with this project type.

I reckon this is due to the Office Upgrade. I don't want to come back to Office 2010 unless it's really necessary.

Do you have any suggestion?

Best regards, jpsfs

BrainSlugs83

My Solution

Okay, so after a lot of banging my head against the wall -- finding out the msbuild properties, conditions, and project inlcudes don't work for/in the ProjectExtensions section, I figured out an additional hack that makes my .csproj work in Visual Studio 2013 [Update 3] whether the developer has Office 2010 or Office 2013 installed (it's detailed in the second bullet point below -- which is not required for the same behavior in VS 2010, YMMV for VS 2012).

To make your project work this way you need to do these three things:

  • Hand edit your .csproj file and find all the office interop assembly references -- make sure the version is set to version "14.0.0.0" (as opposed to "15.0.0.0") and that the "SpecificVersion" child element is present and set to "False".

  • Under the Project\ProjectExtensions\VisualStudio\FlavorProperties\ProjectProperties element find the "OfficeVersion" attribute/value pair and remove it (so the attribute that reads OfficeVersion="14.0" -- delete that). -- Leave all other 14.0s intact, if anything got changed to 15.0, downgrade it back to 14.0 (and again, if it's a reference, set SpecificVersion to false). -- Do not worry about changing any GUIDs, just leave them as they are!

  • At this point, the solution will open and compile on machines that are running Visual Studio 2013 whether they have Office 2010 or Office 2013. -- But it will not start the solution on machines running Office 2013. To fix that:

    • Open regedit and navigate to HKLM\Software\Microsoft\Office\
    • Export the entire 15.0 branch to a .reg file.
    • Open the file in notepad and change all registry path occurrences of "15.0" to "14.0".
    • Re-save the file (make sure you save it as unicode).
    • Import the file & restart Visual Studio. -- This will allow you to start with debugging with Office 2013.

One other thing to keep in mind -- especially if you use EmbedInteropTypes, make sure that when you do your release / publish build that you do it from a machine with Office 2010 (and not 2013) installed, so that the published assembly is built against the Office 2010 specific libraries. -- This will maintain that you have backward and forward compatibility between the two versions.

Again, this worked for me for a Word Add-in -- For an Excel Add-in YMMV.

Original "Answer" (may contain useful details for others)

I mentioned in comments above that I'm having the opposite problem -- VS 2013 Update 3 is forcibly upgrading my projects if the user has Office 2013 installed.

You can try installing VS 2013 Update 3 (even temporarily, say in a VM) and the latest VSTO 2012 / 2013 version, and opening the project, it should forcibly upgrade yours as well. I know you're using Excel, and I'm using Word, but the section it's upgrading:

Old .csproj XML:

<Project ...>
  ...
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
        <ProjectProperties HostName="Word" HostPackage="{20A848B8-E01F-4801-962E-25DB0FF57389}" OfficeVersion="14.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\14.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
        <Host Name="Word"... />
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  ...
</Project>

New .csproj XML:

<Project ...>
  ...
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
        <ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\15.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
        <Host Name="Word"... />
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  ...
</Project>

Looks to me like the two things that changed are:

  • The registry path from 14.0 to 15.0 (which in VS 2010 was easy to work around -- you just created a matching 14.0 registry path that pointed to where you installed Word 2013 and it worked fine).

  • The host package's CLS ID. I don't know what they are for Excel, but you can probably look them up. -- I prefer not to change the CLS ID of the checked in project, such that developers developing & testing the project against Word 2010 can continue to do so, as well as those developing and testing against Word 2013.

Of additional note it looks like two references got updated from 14.0 to 15.0 as well -- this is a major no-no -- since we want to only build against/embed the 2010 Interop Types (these work fine in 2013, but we don't want to accidentally access some 2013 only property and then have it not work in 2010...)

The two references that got updated are "Microsoft.Office.Interop.Word" and "Office".

Edit: Looks like I can set those two references to SpecificVersion: False, and then hand edit the XML file to step them back down to "14.0.0.0" (version seems to be grayed out from the regular menu).

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

ILNumerics and Visual Studio Tools for Office (VSTO)

분류에서Dev

Visual Studio Tools for Office (VSTO)-사용자 가이드 찾기

분류에서Dev

VSTO 2010과 2013 프로젝트의 차이점

분류에서Dev

Microsoft Office 2010/2013의 암호화 설정 변경

분류에서Dev

SharePoint 2010에서 Microsoft Office 2013 interop dll 사용

분류에서Dev

Office 2013과 2010간에 추가 기능 디버그 환경 선택 (Visual Studio 2013)

분류에서Dev

VSTO Microsoft Office Outlook 2013 추가 기능이 계속 리본을 사용하지 않도록 설정

분류에서Dev

c # Excel 2010 VSTO 템플릿

분류에서Dev

Office Solutions for Visual Community 2013?

분류에서Dev

Warmup setting for addins in Office 2013

분류에서Dev

Office 365가 설치된 VS2013 또는 VS2015를 사용하여 Office 2010 추가 기능을 개발할 수 없음

분류에서Dev

Office 2010 won't uninstall OR install

분류에서Dev

Office 2010 won't uninstall OR install

분류에서Dev

Office 2010 won't uninstall OR install

분류에서Dev

Install Office 2010 Standard on another laptop

분류에서Dev

MS Office 상시 개방-2010

분류에서Dev

Office 2010-Excel 문제

분류에서Dev

VSTO Projects cannot be built after installing VS2013

분류에서Dev

MS Project Server 2013 및 Sharepoint 2010

분류에서Dev

TFS 2010 및 Outlook 2013 통합

분류에서Dev

Office 2013에서 EPS 지원

분류에서Dev

Office 2013 제거 중단

분류에서Dev

Office 2013 설치 오류 1406

분류에서Dev

Sharepoint 2013 Office365-DelegateControl

분류에서Dev

Office 2013 용 UI 자동화

분류에서Dev

VBA Office2010 Shapes.PasteSpecial 실패

분류에서Dev

How do I Initiate an OCR scan in Microsoft Office Word 2010?

분류에서Dev

Microsoft Office 2010 용 Open XML SDK 2.0

분류에서Dev

14.04의 Office 2010은 와인 아래?

Related 관련 기사

뜨겁다태그

보관