1

I created a C# library that uses existing COM types and expose some functions via COM.

I added the reference to the existing TypeLib from the Reference Manager in Visual Studio 2013. It automatically creates the interop assembly and embed interop types.

Some of my exposed COM functions have parameters whose types coming from the interop assembly.

Then I register my assembly with the regasm tool (and the /codebase /tlb options).

Problem: the parameters with interop types become IUnknown interfaces!

Here is the warning that regasm show to me:

Warning: Type library exporter could not find the type library for 'Foo.Bar'. IUnknown was substituted for the interface.

For example, my exported function looks like:

MyFunction(IUnknown bar);

Instead of:

MyFunction(Bar bar);

What I am doing false?

EDIT: I have tested with IBar instead of Bar, but that changes nothing.

  • 1
    I wish SO users would stop obfuscating their questions. What the heck is "Bar"? Strictly use interfaces in the arguments, not coclass names. If you don't have the type library then dig it out of the DLL with VS, File + Open + File, Typelib node, resource #1, right-click and export. – Hans Passant Apr 24 '15 at 09:38
  • I tried to use the interface in the arguments, but it doesn't work. Strictly speaking, it is not a TypeLib (tlb), but an executable (exe). I will try your solution, thanks! – Kevin Vuilleumier Apr 24 '15 at 09:57
  • My MS Word (or MS Office) is installed x64 only (not x86) while my Solution in VS was compiled for "Any CPU" (meaning either x86 and x64). I've now compiled my Solution for x64, in compliance with x64 of my Office, and the error does not arise any longer. In Visual Studio go to: Menu-Project-[Project name] Properties-Build-Platform target. – user2.252.275 Apr 28 '18 at 20:45

0 Answers0