Primary Interop Assemblies (PIAs) and Interop Assemblies (IAs) [Office 2003 SDK Documentation]
If you don't know what are primary interop assemblies (PIAs) and interop assemblies (IAs) and what they are for, you will find the following explanations useful. There are some excellent articles already written on these topics available on MSDN.
The following are excerpts from the article entitled Primary Interop Assemblies (PIAs) available on MSDN
What is a PIA?
Like any other managed assembly, an interop assembly is a collection of types that are deployed, versioned, and configured as a single unit. However, unlike other managed assemblies, an interop assembly contains type definitions (not implementation) of types that have already been defined in COM. These type definitions allow managed applications to bind to the COM types at compile time and provide information to the common language runtime about how the types should be marshaled at run time.
While any number of interop assemblies may exist that describe a given COM type, only one interop assembly is labeled the PIA. The PIA contains the official description of the types as defined by the publisher of those types. The PIA may contain certain customizations that make the types easier to use from managed code. The PIA is always signed by the publisher of the original COM type.
Any interop assembly that is not provided by the publisher of the COM types is considered unofficial and should be avoided. Because the types defined in such an assembly are not to be signed by the publisher of the PIA, they are incompatible with the definitions provided in the PIA.
Why are PIAs important?
PIAs are important because they provide unique type identity. The PIA distinguishes the official type definitions from counterfeit definitions provided by other interop assemblies. Having a single type identity ensures type compatibility between applications that share the types defined in the PIA. Because the PIA is signed by its publisher and labeled with the PrimaryInteropAssembly attribute, it can be differentiated from other interop assemblies that define the same types.
The following are excerpts from Office talk column article on the Office Web site on MSDN entitled A Primer to the Office XP Primary Interop Assemblies:
What is an Interop Assembly (IA)?
An interop assembly is a specialized .NET assembly that contains metadata that defines COM types that enable .NET compilers to resolve calls to COM objects. There is an important distinction to remember—an interop assembly only contains definitions of COM types, as it has not modified the original COM library (the actual binary representation). Let me simplify that definition—an interop assembly contains the needed information that allows .NET managed code that runs under the common language runtime to call unmanaged code in Microsoft Office using the various Microsoft Office COM-based object model APIs.
How does an interop assembly differ from that of a primary interop assembly?
For the most part, they are almost identical with the exception of a few noteworthy differences. A primary interop assembly is the official interop assembly released by a software vendor. In the case of the Microsoft Office XP PIAs, Microsoft is the owner of the Office COM-based object model and they have released the official primary interop assembly.
Another difference of a PIA over an interop assembly is that the COM library owner can customize the PIA by renaming or hiding certain elements in the assembly and add attributes to change marshaling behavior between .NET and COM.
Herein lies the importance of using the Microsoft Office XP PIAs over one you would generate yourself with TLBIMP.EXE or Visual Studio .NET. Even though these tools described thus far do a good job in typical scenarios, it is not realistic to expect them to understand the numerous nuances of the deep and extensive Office object models. Microsoft has customized the PIAs to improve interoperability.
So in summary, that was the long version of convincing you that:
- You need an interop assembly for Office and .NET development.
- You should use the primary interop assemblies from Microsoft because they are official.
- The official PIAs are tweaked for better interoperability.
- Microsoft has tested the Office XP PIAs and they are likely to be better than ones you or I would generate on our own.