Signed assembly dependency that references a COM DLL must have the dependency's generated interop assembly referenced

1.3k views Asked by At

Sorry about the terrible title.

I have a signed assembly 'Signed.dll' that is a dependency of another assembly, say Executable.exe.

Signed.dll references a COM DLL and publically exposes one of this COM DLL's types: 'ComPublicT.'

Executable.exe must reference the automatically generated Interop.COM.dll from the Signed project, rather than adding a reference to the original COM DLL.

The error is a type mismatch between two different ComPublicT types from the two different COM interop assemblies.

This is only required if Signed.dll is signed.

Other than creating a type that mimics ComPublicT, how can I allow Executable to reference the COM DLL rather than the Signed's COM interop assembly?

Why does this happen?

Edit, Here is a somewhat different breakdown:

Signed Project references COM.dll, and publically exposes a type from the COM.dll Adding this reference in Visual Studio automatically creates Interop.COM.dll

Executable references and depends on the Signed Project Normally you can add a reference to COM.dll and all is well.

Because Signed is signed, the publically exposed Interop.COM.dll type from Signed is not seen by the compiler as the same as the publically exposed type from Executable's Interop.COM.dll

Executable must manually reference Signed's Interop.COM.dll, which feels fragile.

1

There are 1 answers

0
Cat Zimmermann On BEST ANSWER
  1. Every assembly referenced by a signed assembly must also be signed.

  2. Normally there is a signed Primary Interop Assembly (PIA) provided by the author of the COM DLL. It should be the sole interop assembly for its parent COM types referenced by any .NET assembly. http://msdn.microsoft.com/en-us/library/aax7sdch.aspx There isn't a PIA available in my case.

The two interop assemblies generated by Visual Studio for my two projects differ in that one interop assembly is signed, and the other is unsigned.

Thus, the types contained in the the interop assemblies differ.

One solution is to generate a single signed interop assembly that is referenced by both projects.