Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 304295 - Last Review: May 8, 2007 - Revision: 1.3
How to create a Primary Interop Assembly (PIA)
This article was previously published under Q304295
On This Page
SUMMARY
A Primary Interop Assembly (PIA) contains the official
description of types
as defined by the types publisher. A PIA is an assembly that contains a
signed set of wrapper classes that enables you to call unmanaged code from
managed code.
A PIA is a unique vendor-supplied assembly that contains
the type definitions of types that are implemented by using the Component Object
Model (COM). In a PIA, the type definitions are contained as metadata. The COM type library publisher must sign only
one PIA with a strong name. A
single PIA can wrap more than one version of the same type library.
A
COM type library that is imported as an assembly and that is signed by someone
other than the original type library publisher cannot be a PIA. Only the type
library publisher can create a PIA that becomes the unit of official type
definitions for interoperating with the underlying COM
types.
Requirements
This
article assumes that you are familiar with the following topics:
The following list outlines the recommended hardware, software,
network infrastructure, and service packs that you need:
- Microsoft .NET Framework 1.1 or Microsoft .NET Framework
1.0
Create a Primary Interop
Assembly (PIA)
To create a PIA, follow these steps:
- Create a COM object.
- If you already have
a key file, skip this step. Go to step 3.
If you do not already have a key file, use the
sn.exe tool to create a key file. To do this, run the following command at a
Visual Studio .NET command prompt: - Generate an assembly from the COM type library. To do this,
run the following command at the Visual Studio .NET command prompt:
TLBIMP MyCOMServer.dll /out:MyWrappers.dll
/keyfile:mykey.snk /primary
- Register the generated assembly. To do this, run the
following command at the Visual Studio .NET command prompt:This
command adds the following entries in your registry that designate the assembly
as a PIA:
HKEY_CLASSES_ROOT\TypeLib\<typelib_guid>\version\lcid\PrimaryInteropAssembly\Assembly
HKEY_CLASSES_ROOT\TypeLib\<typelib_guid>\version\lcid\PrimaryInteropAssembly\CodeBase
HKEY_CLASSES_ROOT\TypeLib\<typelib_guid>\version\lcid\PrimaryInteropAssembly\WebService
The Assembly value is mandatory. The Assembly value must specify the full string form of the assembly name,
including the version, the culture, and the publisher key.
The CodeBase value and the WebService value are optional. The CodeBase value specifies the URLs from
where the assembly can be downloaded. The WebService value provides a URL that the .NET Framework can query
to determine the code base of the assembly. - Add the PIA to the Global Assembly Cache (GAC). To do this,
run the following command at the Visual Studio .NET command prompt:
gacutil -i MyWrappers.dll
REFERENCES
For more information about PIAs, visit the following
Microsoft Web site:
APPLIES TO
- Microsoft .NET Framework 1.1
- Microsoft .NET Framework 1.0
| kbinterop kbcominterop kbhowtomaster KB304295 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please