为什么我不应该使用 AutoDual?
到目前为止,我一直使用 [AutoDual]
属性来装饰我想在 VB6 中使用的 .NET 类。重点是在 VB6 环境中获得对 .NET 对象的智能感知。然而,有一天我用谷歌搜索 AutoDual,第一个答案是“不要使用 AutoDual”。
我一直在寻找为什么我不应该使用它的连贯解释,但找不到它。
这里有人可以解释一下吗?
Up to now, I've always decorated my .NET classes that I want to use from VB6 with the [AutoDual]
attribute. The point was to gain Intellisense on .NET objects in the VB6 environment. However, the other day I googled AutoDual and the first answer is 'Do Not Use AutoDual'.
I've looked for coherent explanation of why I shouldn't use it, but could not find it.
Can someone here explain it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了一种可靠的方法,可以为 VB6 中的 .NET 对象提供智能感知,同时又不会破坏接口。关键是用DispatchID标记接口中的每个公共方法/属性。然后该类必须从该接口继承 - 以下面的方式。
调度 ID 为您提供了在类中移动项目的能力,而且您现在可以向类添加新内容,而不会破坏二进制兼容性。
I found a reliable way to both provide Intellisense for .NET objects in VB6, while at the same time not breaking the interface. The key is to mark each public method/property in the interface with DispatchID. Then the class must inherit from this interface - in the manner below.
What the dispatch ID gives you is the ability to move around items in the class, plus you can now add new things to the class and not break the binary compatibility.
我认为这概括了这一点:
http://msdn.microsoft.com/en-us/library/ms182205.aspx
它增加了使用自动双重属性更改该类中的某些内容会在类更改时破坏其他人的代码的可能性。如果让消费者能够做一些很可能在未来给他们带来问题的事情。
http://www.dotnetinterop.com/faq/?q=ClassInterface
我终于找到了有关 AutoDual 的情况及其工作原理的链接:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7fa723e4-f884-41dd-9405-1f68afc72597
I think this sums it up:
http://msdn.microsoft.com/en-us/library/ms182205.aspx
It increases the possibility that changing something in that class with the auto dual attribute will break someone else's code when the class is changed. If gives the consumer the ability to do something that will quite possibly cause them issues in the future.
http://www.dotnetinterop.com/faq/?q=ClassInterface
I finally found the link that talks about what is going on with AutoDual and how it works:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7fa723e4-f884-41dd-9405-1f68afc72597