使 .NET 程序集 COM 可见并适用于 VB5

发布于 2024-08-27 17:33:35 字数 843 浏览 9 评论 0原文

我有一个程序集,我已设法使其对 VB6 可见并且它可以工作,但在使用 VB5 完成同样的事情时遇到问题。

对于VB6,我已经构建了程序集,使其COM可见,将其注册为COM对象等,并且程序集显示在VB6的引用列表中,并允许我成功使用它。对象浏览器还显示组件中的方法。我将程序集及其 TLB 复制到用于 VB5 开发的虚拟工作站,并运行 Regasm,显然成功了:

C:\>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
\regasm arserviceinterface.dll /tlb:arserviceinterface.tlb
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Assembly exported to 'C:\Projects\AR\3rd Party\ARService\arserviceinterface.tlb'
, and the type library was registered successfully

请注意,虚拟 W/S 是 Win2k,并且上面没有 .NET Fx 3.5,只有 2.0。

程序集显示在VB5中可以选择的引用中,但程序集的方法不会显示在对象浏览器中,并且通常无法使用。要么有一个步骤我没有完成,要么VB5不知道如何使用这样的COM对象。请注意,VB5 安装在虚拟工作站上,而不是安装 VB6 的同一工作站上。

有什么想法吗?我想到的一件事是,我可能需要在相关工作站上生成并使用强名称,但是......

I have an assembly which I have managed to make visible to VB6 and it works, but having a problem accomplishing the same thing with VB5.

For VB6, I have built the assembly, made it COM-visible, registered it as a COM object etc., and the assembly shows in VB6's References list, and allows me to use it successfully. The Object Browser also shows the method in the assy. I copied the assembly and its TLB to a virtual workstation used for VB5 development, and ran Regasm, apparently successfully:

C:\>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
\regasm arserviceinterface.dll /tlb:arserviceinterface.tlb
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Assembly exported to 'C:\Projects\AR\3rd Party\ARService\arserviceinterface.tlb'
, and the type library was registered successfully

Note that the virtual W/S is Win2k and does not have .NET Fx 3.5 on it, just 2.0.

The assembly shows up in the References that can be selected in VB5, but the method of the assembly doesn't show up in the Object Browser, and it is generally unusable. Either there is a step to do that I haven't done, or VB5 doesn't know how to use such a COM object. Note that the VB5 setup is on a virtual workstation, not the same workstation that VB6 is installed on.

Any ideas? One thing that occurred to me is that I might need to generate and use a strong name on the workstation in question, but...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没企图 2024-09-03 17:33:35
  1. 确保您的程序集不是针对 .Net 3.5 中的功能构建的,也不是使用 .Net 3.5 中的功能
  2. 复制 OLE/COM 对象查看器工具(您可以从安装了 Windows SDK 的计算机上获取它)。运行它,转到查看所有对象,向下滚动列表到您的对象,然后右键单击它以创建一个实例。
    2.1 如果 OLE/COM 对象查看器无法创建实例,则问题在于该对象如何在计算机上注册,或者如何安装 .Net。
    2.2 如果OLE/COM对象查看器可以创建实例,那么问题就在于VB5如何使用。
  3. 我不记得 VB5 是否确实支持早期绑定(基于 IUnknown 的对象)或者是否仅支持后期绑定(IDispatch)。我偷偷怀疑VB5只支持dispinterfaces,而VB5.5引入了对IUnknown的支持。所以这可能是你的问题。
  1. Make sure your assembly is not build against and using features from .Net 3.5
  2. Copy the OLE/COM Object Viewer tool (you can get it from a machine with the Windows SDK installed). Run it, go to View All Objects, scroll down the list to your object and right click on it to create an instance.
    2.1 If OLE/COM Object Viewer can't create an instance, the problem is in how the object is registered on the machine, or how .Net is installed.
    2.2 If OLE/COM Object Viewer can create an instance, then the problem is in how VB5 consumes.
  3. I can't remember if VB5 actually supports early-binding (IUnknown-based objects) or if supports only late-binding (IDispatch). I have the sneaking suspicion that VB5 only supported dispinterfaces, and it was VB5.5 that introduced support for IUnknown. So that could be your problem.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文