Click here to Skip to main content
14,977,259 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an in-process COM Service written in C++. The COM interface is defined by an IDL file.
I have a C# application that uses that COM interface.
I modify the IDL of the C++ COM Service, re-compile and re-register it.
But the interface change is not being seen when I re-compile the C# application.
Visual Studio seems to be caching the original interface definition somewhere and not updating it. Even if I remove the COM reference from the C# project and re-add it I still see the old interface.

Does anyone know how to force an update of the COM interface so I can compile the C# app with the revised interface?

This is with Visual Studio 2015.

What I have tried:

Various combinations of cleaning and re-compiling everything.
Updated 12-May-21 22:28pm
Shao Voon Wong 12-May-21 23:35pm
Did you unregister the old COM object before registering the new one? You can remove the old COM reference from the C# project and add new one again and recompile.

1 solution

I've found a solution to this. The steps are
1. Recompile the C++ Service.
2. Locate the TLB file for the service. It will be in the same place as the OBJ files for the project.
3. Use TLBIMP to generate a .Net DLL for the service.
4. Register the DLL using REGASM.
5. Re-open the C# project and re-build. It will now get the updated interface definition.
Shao Voon Wong 14-May-21 2:13am
I suggest you put these steps in the post-build event of the C++ COM project so that your C# project always gets the latest COM object.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900