How to create a Primary Interop Assembly (PIA) (304295)
The information in this article applies to:
- Microsoft .NET Framework 1.1
- Microsoft .NET Framework 1.0
This article was previously published under Q304295 SUMMARYA 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. back to the topRequirementsThis
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
back to the topCreate 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:sn -k mykey.snk - 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:
regasm MyWrappers.dll 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 back to the
topREFERENCESFor more information about PIAs, visit the following
Microsoft Web site: back to the
top
Modification Type: | Major | Last Reviewed: | 1/8/2004 |
---|
Keywords: | kbinterop kbCOMInterop kbHOWTOmaster KB304295 kbAudDeveloper |
---|
|