Strongly-named imported COM libraries

When you import a COM library using the Add Reference option in VS .NET, the generated assembly is not strongly named. This will stop you from emitting the assembly that's consuming the COM library with a strong name.

To fix this, use the TLBIMP utility in the .NET SDK. This can accept either a /keyfile:, /keycontainer: or /delaysign: switch that will enable you to control the key that is used to sign the assembly.

TLBIMP c:\myapp\whatever.dll /keyfile:c:\mykeys\key.snk /out:Interop.Whatever.dll

The /out: switch is particularly important here. By default, VS .NET prefixes its assemblies with Interop. To be consistent, you should do the same.

1 Comment

  • Actually, you can fix this straight from the VS.NET IDE. In the Solutions Explorer, right click on the Project name and select "Properties". In the "Properties" window, go to "Common Properties" --> "General". Here you'll see a setting called "Wrapper Assembly Key File". Place the path to your keyfile here. Now the IDE will sign COM Interop assemblies properly.

Comments have been disabled for this content.