开发者

Replace native C++ COM .dll with .NET COM .dll

开发者 https://www.devze.com 2023-02-21 18:59 出处:网络
Our customer has old Win32 client开发者_运维知识库s that use a native C++ COM registered .dll that we provide.

Our customer has old Win32 client开发者_运维知识库s that use a native C++ COM registered .dll that we provide.

We want to replace the native .dll with a .NET version. So we've built the .NET dll and COM registered it. We have native C++ test clients that are able to handle the swap from the old .dll to the new, but... it seems we need to recompile them for it to work.

Is there some logical reason why we need to recompile the test client, or are we doing something wrong?

We cannot require our customer to recompile their clients.


Maybe you forgot to use the [Guid] attribute on the interface and the class declarations. They have to match the IIDs and CLSID that were used in the IDL for the old C++ project. Or the functions are not in the same order anymore. Or they don't have the same DISPID, in case the client code uses them late-bound.

The best way to avoid this is to add a reference to the old type library in your .NET project so you can use the old interfaces in your code. You still need to get the [Guid] of the class that implements the interfaces right so it has the correct CLSID.

You can use the OleView.exe tool, View + Type Library to compare the old and the new type library. Copy/paste the generated IDL and diff it. You get the new type library from Regasm.exe /tlb. Any mismatch might (and likely will) be a problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消