PRB: PIA Is Not Found When You Reference an Office Type Library in Visual Studio .NET
This article has been archived. It is offered "as is" and will no longer be updated.
When you develop a solution for a Microsoft Office 2003 application by using Microsoft Visual Studio .NET 2003, and you reference an Office object library in that solution, you notice that Visual Studio .NET 2003 creates an Interop Assembly (IA) for the library instead of referencing the Primary Interop Assembly (PIA).
Additionally, there is another symptom of this same problem. When you try to create a new Office project by using Microsoft Visual Studio Tools for the Microsoft Office System 2003, you receive the following error message:
The primary interop assembly required by this project is not installed in the global assembly cache. Microsoft Office 2003 includes the primary interop assemblies for each application as an installation option. For details on installing the Office primary interop assemblies, see the Help topic, "Installing Office Primary Interop Assemblies."
This problem may occur for either of the following reasons:
- The PIA for the Office object library that you select is not installed in the Global Assembly Cache (GAC).
To install the PIA in the GAC, you must have the PIA for the Office application or the PIA for the Office component marked as Run from My Computer in Microsoft Office 2003 Setup. In Office Setup, each Office PIA is listed under the corresponding application for the PIA as a .NET Programmability Support feature.
- The PIA is installed in the GAC, but a registry entry is missing.
When you select a reference to an Office object library in the development environment, Visual Studio .NET uses the registry to locate the PIA that corresponds to the object library that you select. This registry entry may be removed if the Office object library of the application is registered by a newly installed program or sometimes if the application executable for that object library is run with the regserver switch.
To resolve this problem, Microsoft recommends that you run Office Setup from Add or Remove Programs in Control Panel:
- If the PIA does not appear in the GAC, run Office Setup and then mark the PIA for the application as Run from My Computer. Each Office PIA appears as a .NET Programmability Support feature for the corresponding Office application or for the corresponding Office component.
- If the PIA does appear in the GAC, run Office Setup and then select the option to repair your Office installation. Alternatively, if the PIA does appear in the GAC, you can run the regasm utility to restore the missing registry entries.
- In Control Panel, double-click Administrative Tools, and then select Microsoft .NET Framework 1.1 Configuration.
- Select Assembly Cache, and then click Assemblies on the View menu.
- Right-click Assembly in the Assemblies list, and then click Properties.
In the Assembly Properties dialog box, notice the Assembly Name, the Version, and the Public key token.
For example, if you select the Microsoft Word PIA, you notice the following property values:
Assembly Name: Microsoft.Office.Interop.Word
Public Key Token: 71e9bce111e9429c
- Start a Visual Studio .NET command prompt.
- At the command prompt, change to the directory where the assembly is located.
The path is in the following form:%windir%\assembly\GAC\<assemblyname>\<version>__<public key token>For example, if you use the property values for the Word PIA that are mentioned earlier, you must change to the directory where the Word PIA is located by using the following command:cd %windir%\assembly\GAC\Microsoft.Office.Interop.Word\184.108.40.206__71e9bce111e9429c
- Run the regasm utility to restore the Word PIA registry entries:regasm Microsoft.Office.Interop.Word.dll
Article ID: 823996 - Last Review: 12/08/2015 03:36:05 - Revision: 1.5
Microsoft Office Professional Edition 2003, Microsoft Office Basic Edition 2003, Microsoft Office Small Business Edition 2003, Microsoft Office Standard Edition 2003, Microsoft Office Students and Teachers Edition 2003, Microsoft Visual Studio .NET 2003 Professional Edition, Microsoft Visual Studio .NET 2003 Enterprise Developer, Microsoft Visual Studio .NET 2003 Enterprise Architect, Microsoft Visual Studio Tools for the Microsoft Office System version 2003
- kbnosurvey kbarchive kbprb KB823996