Adding the Office Primary Interop Assemblies as a Prerequisite in your ClickOnce installer (Mary Lee)

Rate This
  • Comments 46

When you use ClickOnce in Visual Studio 2008 to deploy your Office solution, you can include prerequisites such as the .NET Framework 3.5, the Visual Studio Tools for Office system 3.0 Runtime, and Windows Installer 3.1.  However, the primary interop assemblies (PIAs) for the 2007 Microsoft Office system are not automatically listed in the Prerequisites dialog box. 

Fortunately, you can add the PIAs to the Prerequisites dialog box. The following procedure adds the 2007 Microsoft Office Primary Interop Assemblies to the Prerequisites Dialog Box. This procedure may look lengthy, but you only have to do it once.

1.  Download the OfficeVSTO2005SEWindowsInstallerV3.msi sample, which is part of the deployment whitepaper at Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer (Part 1 of 2).

2. Install OfficeVSTO2005SEWindowsInstallerV3.msi.

3. Copy the contents of %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\packages to %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

4. Compile the component checker. This step checks if the computer has the correct version of Office installed to match the PIAs that are being installed.

a) Open a Visual Studio command prompt

b) Change directories to %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\projects\Checks

c) Type the following command: cl.exe /Oxs /MT /GS ComponentCheck.cpp advapi32.lib

d) Copy ComponentCheck.exe to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder and the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2003PIA folder.

5. Download and extract the Office 2007 PIAs from 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies.

6. Copy the o2007pia.msi file to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder.

7. In VS2008, on the Project menu, click ProjectName Properties.

8. Click the Publish tab.

9. Click the Prerequisites button to open the Prerequisites dialog box.

You should see the PIAs listed in the Prerequisites dialog box like the following image. Because the package.xml file does not define a HomeSite (a location to download the file), you will see a build warning.  Even if you have selected Download prerequisites from the component vendor's web site, the PIAs will go into a directory alongside your solution installer.

Prerequisites

If you want to learn more about adding your own entries to the Prerequisites dialog box, see Adding Custom Prerequisites.

For more information about common problems when deploying the Office primary interop assemblies, see http://blogs.msdn.com/vsto/archive/2008/05/20/common-pitfalls-during-pia-deployment-and-installation.aspx.

For troubleshooting assistance, try the VSTO Power Tools, a suite of tools to help you develop and deploy Office solutions. For example, you can use the VSTO Troubleshooter to examine end user computers for missing prerequisites.

Mary Lee, programming writer.

Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post
  • hi Martin,

    you can skip step 4 if you can't compile ComponentCheck.cpp.  however, the PIAs will always install, rather than looking to install only if they aren't already there.

    if you do skip step 4, you'll have to modify the product.xml and remove these lines:

     <PackageFile Name="ComponentCheck.exe" />

    and

    - <InstallChecks>

     <ExternalCheck Property="Office2007Exists" PackageFile="ComponentCheck.exe" Arguments="{0638C49D-BB8B-4CD1-B191-050E8F325736}" />

     </InstallChecks>

    m.

  • Thx - I'll settle for that for now, but now I have installed the Windows SDK, and i now seem to be missing an except-h file??

    And one more thing - when compiling the setup-project now, i get this error :

    The value of the 'PublicKey' attribute in 'Microsoft Visual Studio 2005 Tools for Office Second Edition runtime' does not match that of file 'C:\Programmer\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\VSTOSERuntime\vstor.exe'.

    WHat does that mean?

    And last -but not least -  the Setup-applikation when run on a client PC, comes up with an error regarding the vsto-installation...

    "Setup has detected that the file "vstor.exe" has changed since it was initially publised. CLick OK to retry the download, or cancel to exit setup"

    Clicking OK just brings up the same message.... I guess it has something to do with the warning during compiliation of the setup-appication.

  • Martin,

    here's a short summary:

    to get the header files for excpt.h, install the C++ components for Visual Studio.

    to get rid of the error message about VSTO 2005 SE runtime, use the package.xml and product.xml files in the sample that is attached to the VSTO 2005 deployment whitepaper: http://go.microsoft.com/fwlink/?LinkId=83721

    m.

  • Hi I have created an workbook solution using c#.net 2005, i have also installed my solution, This_Startup

    I have given a simple message box("hello world");

    but when i open excel workbook it doesn't come why?

    and where i locate my setup whose name is "setup123" in excel2003 professional edition sp3;

  • hi Chandra,

    there are a number of steps to complete before an Office 2003 solution can be deployed with VS2005.

    1. check for and install prerequisites: .NET FX 2.0, VSTO 2005 SE runtime, and the primary interop assemblies.  

    2. copy the customization assembly and workbook file to the end user computer.  

    3. grant full trust to the customization assemblies by creating a solution group for the entire solution and a code group for each DLL inside the solution group.

    there are step-by-step instructions to set up your development computer and setup project at http://go.microsoft.com/fwlink/?LinkID=57779 and http://go.microsoft.com/fwlink/?LinkID=57780.

    if you have other questions, you can search and post in the VSTO forum at http://forums.microsoft.com/Forums/ShowForum.aspx?ForumID=16&SiteID=1

    m.

  • In the final paragraph, you say "Even if you have selected Download prerequisites from the component vendor's web site, the PIAs will go into a directory alongside your solution installer."

    Is there a way to tweak package.xml so that it *does* download the PIAs from the MS site? I really don't want to have to include them in my own redistribution package.

    As an alternative, could I put the PIA MSI separately on an internal (intranet) site, and use *that* as a HomeSite?

  • Brad,

    you can modify the package.xml manifest to point to your own intranet site.  the PIA sample is simply one implementation of creating a custom prerequisite as documented here: http://msdn.microsoft.com/en-us/library/ms165429.aspx

    m.

  • Thanks for that. I got the HomeSite part working great from my own intranet. Now for a followup...

    For some reason, when I run my Setup it *always* wants to install the PIAs again, even though I know they're already installed. Almost as though ComponentCheck is failing for some reason.

    I am using VS 2008 and VSTO 3.0. Is it possible I need to create my ComponentCheck a different way?

  • Hmm, so ComponentCheck I built from the VSTO 3.0 Deployment Whitepaper example returns 0 if the PIAs *are* present, but in product.xml the "BypassIf" statement bypasses the install if the value is *not* equal to zero.

    I have the sneaking feeling something's amiss somewhere. Changing BypassIf now doesn't try to reinstall the PIAs every time. My next test is to set up a VM without them and make sure they *do* install.

    I assume others have done this, so I *can't* be the first to run into this, which makes me question my sanity somewhat.

  • In answer to Brad's comments, product.xml from the whitepaper has a bug.  To get it to work properly, you have to change this line:

    <BypassIf Property="Office2007Exists" Compare="ValueNotEqualTo" Value="0" />

    to this:

    <BypassIf Property="Office2007Exists" Compare="ValueEqualTo" Value="0" />

    See this posting:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2413500&SiteID=1

  • Actually, I just discovered that Visual Studio 2008 Service Pack 1 adds the Office 2007 PIAs to Visual Studio's list of available prerequisite packages.  You no longer have to take any of the steps outlined in Mary's original post.

    Hallelujah!

  • Visual Studio Tools for Office 3.0 (VSTO) is the latest release of VSTO since the 2005 SE release. If

  • Hi,

    Thanks I don't know much about it,

    but I followed steps provided by you and it worked fine.

    Once Again Thank You Very Much.

    Regards,

    japan shah

  • I can't get the primary interop assemblies to appear in the prerequisites list of options.

    Can you clarify where I would see the following in VS 2008?

    "In VS2008, on the Project menu, click ProjectName Properties.

    8. Click the Publish tab.

    9. Click the Prerequisites button to open the Prerequisites dialog box"

    I can't locate a Publish tab when I right-click the project

    Or provide a very simple guide as to how I can achieve this.  I've followed the white pages guide to the letter but I still cannot get this appear - I'd like to use the SP1 pproach described above but unfortuately this is not an option.

  • hi Mihael,

    in the Solution Explorer, make sure that you have your project selected, not the solution.

    for example, if i create an Excel Add-in project, this is what i see in the Solution Explorer.  

    Solution 'ExcelAddIn1' (1 project)

    - ExcelAddIn1

      + Properties

      + References

      + Excel

       |__ ThisAddIn.cs

    (to see the Solution Explorer, on the View menu, click Solution Explorer)

    make sure you select ExcelAddIn1.  then go to the Project menu and click ExcelAddIn1 Properties.

    m.

Page 2 of 4 (46 items) 1234

Adding the Office Primary Interop Assemblies as a Prerequisite in your ClickOnce installer (Mary Lee)