0

I have a C++ project and a c# project. The C# project accesses methods of the C++ project through 2 interop dlls called interop.X.dll and interop.XCom.dll.

When my C++ project rebuilds it creates X.tlb and XCom.tlb files, it also creates x_i.c, x_h.h, xCom_i.c, xCom_h.c files. I have found that the files are created due to project settings in "configuration properties -> MIDL -> output", as displayed below;

enter image description here

What I need to know is how to create the 2 interop dlls, which doesn't get created automatically, using the .tlb and other c files. I have tried using tlbimp x.tlb /out:Interop.x.dll, but the created dll doesn't seem to work.

Thanks.

Madz
  • 1,273
  • 2
  • 18
  • 35
  • 1
    Why not just bypass tlb references and instead just add a direct COM reference? –  Jun 28 '17 at 03:03
  • The projects were not created by me. So I don't want to change them too much. – Madz Jun 28 '17 at 03:04
  • 1
    Huh? Adding a COM reference from .NET to your COM library requires **zero change** on the COM project. Anyway, I thought VS created the interop dlls when you add a COM reference? –  Jun 28 '17 at 03:20
  • Ok.. How do I add a COM reference to my C++ project, forgive my ignorance but I haven't dealt with COM objects before. – Madz Jun 28 '17 at 04:03
  • 1
    tlbimp should work, with proper parameters. What doesn't work this tlbimp exactly? – Simon Mourier Jun 28 '17 at 05:54
  • You put me in the correct path, I was able to add COM references to my C# project and it created the interop dlls for me. Thanks. – Madz Jun 28 '17 at 09:53

1 Answers1

1

This is a summary of my comments above.


Why not just bypass tlb references and instead just add a direct COM reference?

Adding a COM reference from .NET to your COM library requires zero change on the COM project. VS creates the interop dlls when you add a COM reference from your .NET project