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

Published 08 May 08 02:21 PM

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.

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Windows » Adding the Office Primary Interop Assemblies as a Prerequisite in… said on May 8, 2008 7:33 PM:

PingBack from http://windows.wawblog.info/?p=12182

# Maarten van Stam said on May 9, 2008 6:13 AM:

Can you elaborate on what you are doing in step 4 and why this is done?

Thanks

-= Maarten =-

# VSTO Team said on May 9, 2008 11:32 AM:

hi Maarten -  thanks so much for providing quick comments.  step 4 looks at the version of Office that is installed - to ensure that the correct version of the PIAs are being installed.  if a different version of Office is on the end user computer, then the PIAs are not installed.

m.

# tvancil said on May 12, 2008 7:11 PM:

I had to update step 4, part d from  d) Copy ComponentCheck.exe to %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages.

TO

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

to get the addin project to compile.  Is this incorrect?

# VSTO Team said on May 12, 2008 7:15 PM:

the ComponentCheck.exe should go into the PIA folder.  i've updated the path to be correct.  thanks for pointing that out!

m.

# Abhi said on May 15, 2008 12:18 PM:

This was an excellent article  - thank you. What steps do I need to change if I was distributing my Visio Add In,  I created using Visio 2008 , to the user community running Office 2003?

You help is greatly appreciated

# VSTO Team said on May 16, 2008 12:22 PM:

hi Abhi,

if you followed step 3, you already have the Office2003PIA folder in your VS bootstrapper directory.  that means if you go to the Project menu, click <ProjectName> Properties, click Publish, and then click Prerequisites, you should see "Microsoft Office 2003 Primary Interop Assemblies" in the list of prerequisite components to add to your installer.  also, for the Office 2003 PIAs, you don't need to copy the ComponentCheck.exe to that directory.

though you will not be able to use ClickOnce to deploy your Office 2003 solution, you can use a Setup and Deployment project and access the Prerequisites dialog box through there.

m.

# VSTO Team said on May 16, 2008 12:51 PM:

to be more specific, Chris Castillo has blogged about deploying VSTO/Visio add-ins at http://blogs.msdn.com/chcast/.  while the blog entry is VS2005 specific, the steps for VS2008 are similar because  the VSTO 2005 SE runtime is used for Office 2003 solutions by both versions of VS.

# Abhi said on May 19, 2008 5:24 PM:

Hi,

So I removed the Componentcheck.exe from the Office2003PIA folder under bootstrapper directory. Now I cannot compile the add in setup because it gives me the error -

" Error 6 Could not find required file 'c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2003PIA\ComponentCheck.exe' for item 'Microsoft Office 2003 Primary Interop Assemblies'. "

And if I put it back, i can compile but keep getting this new error on the user machine -

"Error 1001: Unable to get installer types in the <assembly.dll> -> Unable to load one or more of the registered types. Retrieve the LoaderException property from more information"

Any help is greatly appreciated.

# Abhi said on May 20, 2008 2:20 PM:

Hi,

So Now I have reached a stage where the add in works fine on my development machine but it does not load when deployed through the setup (using msi installer) on the user machine. I have included the following as prerequisite , considering i built this in VS 2008 and deploying on Office 2003 user machine -

- .net 2.0

- 2003 primary interop assembly

- visual studio 2005 tools for office se runtime

but again yes i do need to include the ComponentCheck under the Office2003PIA because VS2008 will not build the setup program without it.

Now the install completes ok on the user machine but the add in does not work.

PLEASE , someone HELP

# VSTO Team said on May 20, 2008 3:04 PM:

hi Abhi,

the definitive whitepapers to deploy Office 2003 solutions with a setup project are at the following links:

http://go.microsoft.com/fwlink/?LinkID=57779

http://go.microsoft.com/fwlink/?LinkID=57780

these are important to read because the security and deployment models are entirely different for Office 2003 and Office 2007.

if you have specific problems with your deployment, please post your question with error messages at the VSTO MSDN forum at http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=16&SiteID=1

there are many people there who can assist you better than through blog comments.

thanks for all your feedback!

m.

# Karen said on June 17, 2008 10:38 AM:

The best article to overcome the missing Primary Interop Assemblies. You are great!

# Craig said on June 30, 2008 10:31 AM:

Should it not be %ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\ ?  I certainly don't have a %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\ directory.  Using %ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\ instead worked for me.  I could not see the Primary Interop Assemblies or the VSTO Runtime listed in the Prerequisites list in VS 2005 when creating a setup project for a Word 2007 AddIn project.

Thanks.

# VSTO Team said on July 7, 2008 12:30 PM:

hi Craig,

this blog entry is for VS2008, so the path is correct.  

for VS2005 information, you can click on the "Adding Custom Prerequisites" link in the last line of the blog entry.  click "Other versions are also available for the following: Microsoft Visual Studio 2005/.NET Framework 2.0" in the box in the upper right of the topic to go to the VS2005 topic.  this topic lists list \Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages as the correct path for VS2005.

m.

# Martin Moesby said on August 11, 2008 4:07 PM:

Great article - but a minor setback in regards to item 4 :

I dont have the header files required for compiling the ComponentCheck - so, what do I do now?

# VSTO Team said on August 11, 2008 4:25 PM:

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.

# Martin Moesby said on August 11, 2008 4:54 PM:

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.

# VSTO Team said on August 11, 2008 7:06 PM:

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.

# Chandra Kumar Gupta said on August 14, 2008 8:37 AM:

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;

# VSTO Team said on August 14, 2008 10:56 AM:

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.

# Brad said on August 18, 2008 9:52 PM:

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?

# VSTO Team said on August 19, 2008 12:48 PM:

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.

# Brad said on August 19, 2008 6:05 PM:

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?

# Brad said on August 19, 2008 7:07 PM:

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.

# Tony said on August 21, 2008 12:44 PM:

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

# Tony said on August 21, 2008 6:41 PM:

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!

# Chris Hopkins' Visilog said on August 29, 2008 12:35 PM:

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

# Japan Shah said on September 19, 2008 8:13 AM:

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

# mihael holland said on September 20, 2008 6:48 AM:

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.

# Mary said on September 22, 2008 1:18 PM:

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.

# Jim O'Neil's Blog said on October 7, 2008 12:39 AM:

First things first.... you can download the content from my SkyDrive below. Next, let's address the unanswered

# Japan Shah said on October 10, 2008 12:45 PM:

Thanks a lot,

I have done everything for office 2003 PIA and Office 2007 PIA for prerequisites,

and the binaries, I have uploaded to the rapidshare for the other users, who don't want to waste the time to build the .cpp files and downloading the PIA's from microsoft's site,

here is the blog URL: http://office-development.blogspot.com/

# Terry Downing said on October 21, 2008 2:47 PM:

There appears to be a bug in the product.xml file for the Office2003PIA.  Product.xml Lines 25 and 39 specifiy o2003pia.msi when the file is actually o2003pia.exe.  Changing this clears the errors encountered when building a setup project.

# Chris Hopkins' Visilog said on November 13, 2008 6:03 PM:

In a previous post I gave you a brief description of Click-Once vs. Windows Installer based deployment

# Pavan said on February 10, 2009 10:45 PM:

I want to install 0ffice 2003 PIA using BootStrapper.

I had a problem that,

Iam using the following link in Product.xml. "http://download.microsoft.com/download/8/3/a/83a40b5a-5050-4940-bcc4-7943e1e59590/O2003PIA.EXE"

So it  not downloading "o2003pia.msi" from the above url and throwing the following error.

Error:

Setup has detected that the file 'C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\VSDB7.tmp\O2003PIA\O2003PIA.msi' has either changed since it was initially published or may be corrupt.

# shantanu said on February 11, 2009 3:50 AM:

I am facing a wierd problem. I have developed an Excel 2007 Addin using c# in VS 2008. The addin is working fine on my PC. Now when i create a setup and install the same addin on anather PC the installation is successful but the New Component does not show in the excel 2007 ribbon on the PC. Kindly help, its really stuck

Thanks and regards

Shantanu

# Pavan said on February 11, 2009 7:01 AM:

I have few solutions for this problem. Just try with the following things.

1. Install Office 2007 PIA's.

  http://download.microsoft.com/download/4/7/9/4792dd7c-c06d-456e-a8be-2d5176e6f618/Office2007PIA/o2007pia.msi

Then Install your Addin.

2. Even then if it is not working, remove all the registry entries of your addin. The install your addin.

# VSTO Team said on February 12, 2009 10:38 AM:

@Terry: about your text:

Terry Downing said on October 21, 2008 2:47 PM:

There appears to be a bug in the product.xml file for the Office2003PIA.  Product.xml Lines 25 and 39 specifiy o2003pia.msi when the file is actually o2003pia.exe.  Changing this clears the errors encountered when building a setup project.

the product.xml is correct.  you need to run the O2003pia.exe to extract three file: o2003pia.msi, a readme file, and a EULA file.

m.

# shantanu said on February 12, 2009 8:49 PM:

Hello All

Thanks for the comments. But still addin is not loading on the client machine. I will be highly obliged if anyone can provide me the steps of Setup and Deployment for C# Excel 2007 project in Visual studio 2008. It will help me a lot .

thanks and regards

Shantanu

# Pavan said on February 13, 2009 3:40 AM:

Hi Shantanu,

I think there is a problem in your setup.

Please follow the below steps.

1. Create a setup project.

2. Then right click on setup project select  Add -> Project Output . Select your Add in project and select Primary output and click on Ok.

3. Again right click on setup project select  Add -> Project Output . Select your Add in project and select Content Files and click on Ok.

4. Then add .vsto and .dll.manifest files of your addin project which we will get in bin\debug folder.

5. Finally create registry entry under HKCR like  Software -> Microsoft -> Excel -> Addns -> ur AddinName . Create  

Name                            Value

LoadBehaviour           3                            

Manifest                      “[TARGETDIR]UrAddin.vsto|vstolocal”

Here LoadBehavior is {Binary value} and Manifest is {String value}.

# shantanu said on February 15, 2009 8:49 PM:

Hi Pavan

i dont know what is missing but its still not working.

# Michaelb said on July 6, 2009 5:23 PM:

Worked great for me thanks....

# Alan said on August 17, 2009 1:13 PM:

For some reason, PIA doesn't show up as a pre-requisite to my Excel 2007 Add-in project (which registers as a Com add-in).  Why is this?  When I install on the end-user machine it requests the Microsoft.Office.Interop.Excel assembly.... because of this I can't enforce it as a prerequisite.

# VSTO Team said on August 17, 2009 2:30 PM:

Alan,

the PIAs for Microsoft Office 2007 do not appear automatically in the Prequisites Dialog Box until Visual Studio 2008 SP1. you can either install VS2008 SP1, or you can create the bootstrapper package for the Microsoft Office 2007 PIAs by following the instructions in this blog entry.

m.

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About VSTO Team

This login represents the Visual Studio Tools for Office team. Many members of the team us this account for publishing technical blog posts.

This Blog

Syndication

Page view tracker