每次生成 dll 时,如何告诉 vb6 不要创建新版本的接口/com 对象? [英] How do I tell vb6 not to create new versions of interfaces/com objects everytime I make dll?

查看:19
本文介绍了每次生成 dll 时,如何告诉 vb6 不要创建新版本的接口/com 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 .NET 代码使用的 vb6 com 服务器(ActiveX DLL 项目)

I have vb6 com server (ActiveX DLL project) that is used by .NET code

每次我对 vb6 代码进行更改并生成 dll 时,我也必须重新编译我的 .NET 客户端代码,因为看起来 VB6 会生成新的 GUID 或接口和 com 对象的版本.

Everytime I put changes into vb6 code and make dll, I have to recompile my .NET client code as well, because it looks like VB6 generates new GUIDs or versions to interfaces and com-objects.

我承认这是一个很好的做法,因为进行了更改,但我想禁用此行为,以便每次更新 vb6 dll 时我的 .NET 客户端代码都相同.

I admit it's a good practice because changes are made but I'd like to disable this behavior to let my .NET client code be the same everytime I update my vb6 dll.

无论对 COM 对象或 COM 接口进行了哪些更改,我如何告诉 VB6 保持 ActiveX dll 的所有 GUID 和版本相同?

How can I tell VB6 to keep all GUIDs and versions for ActiveX dll the same no matter what changes are done to COM objects or COM interfaces?

推荐答案

Project + Properties, Components 选项卡中的选择很重要.您必须在此处选择二进制兼容性"以强制它重新使用旧的 guid.并保留一份 DLL 副本作为提供 guid 的主人",将其签入源代码管理.

The selection in the Project + Properties, Components tab matters. You have to select "Binary compatibility" here to force it to re-use old guids. And keep a copy of the DLL around to act as the "master" that provides the guids, check it into source control.

当您添加新类时,您还必须更新该副本,以便将来的版本知道为那些添加的类重用相同的 guid.容易忘记,当你忘记时很难诊断.

When you add new classes then you also have to update that copy so future versions will know to reuse the same guids for those added classes. Easy to forget, pretty hard to diagnose when you do.

这是非常危险的,重用 guids 是一个非常强大的 DLL Hell 诱导器.只要小心避免更改现有方法,您就可以让旧的客户端程序继续使用新的 DLL.不仅是他们的方法签名,还有他们的实现.遇到旧版本 DLL 的更新客户端将以一种非常令人讨厌的方式失败,访问冲突崩溃几乎无法诊断.

It is very dangerous, reusing guids is a very strong DLL Hell inducer. You can get old client programs to continue using the new DLL as long as you careful avoid changing existing methods. Not just their method signature but also their implementation. An updated client that encounters an old version of the DLL will fail in a very nasty way, the access violation crash is near impossible to diagnose.

这篇关于每次生成 dll 时,如何告诉 vb6 不要创建新版本的接口/com 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆