如何正确注册 VB.NET COM+ 组件的类型库? [英] How do I properly register the Type Library of A VB.NET COM+ Component?

查看:17
本文介绍了如何正确注册 VB.NET COM+ 组件的类型库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将旧的 VB6 COM+ 组件升级到 VB.NET 组件.我似乎已经升级了一个叫做 EventPackage,它有一个类,IEventListener.另一个,TradeOrders,Implements EventPackage.IEventListener.尝试构建 TradeOrders 时,我收到以下错误/警告;

I am looking to upgrade legacy VB6 COM+ components to VB.NET components. I have seemingly upgraded one already, called EventPackage, which has one class, IEventListener. Another, TradeOrders, Implements EventPackage.IEventListener. When attempting to build TradeOrders, I get the following Errors/Warnings;

  1. 无法加载引用EventPackage"的类型库.图书馆未注册.(来自 HRESULT 的异常:0x8002801D (TYPE_E_LIBNOTREGISTERED))
  2. 找不到引用的组件EventPackage".
  3. 未定义类型EventPackage.IEventListener".

在 .vbproj 中,我注意到这个引用

In the .vbproj, I notice this reference

<COMReference Include="EventPackage">
  <Guid>{0D76C094-21A6-4E04-802B-6E539F7102D7}</Guid>
  <Lcid>0</Lcid>
  <VersionMajor>2</VersionMajor>
  <VersionMinor>0</VersionMinor>
  <WrapperTool>tlbimp</WrapperTool>
</COMReference>

当我在注册表中搜索此 Guid 时,我什么也没找到.当为类似的 COM+ 对象使用 GUID 时,我在 HKEY_CLASSES_ROOT\CLSID\{...}\TypeLib 中找到它们(..."是另一个组件的 GUID).到EventPackage.IEventListener对应的注册表键名,发现没有\TypeLib子键.正如您可能怀疑的那样,在 reg 中搜索0D76C094-21A6-4E04-802B-6E539F7102D7"不会产生任何结果.

When I search the registry for this Guid, I find nothing. When using GUIDs for similar COM+ objects, I find them in HKEY_CLASSES_ROOT\CLSID\{...}\TypeLib ("..." being the GUID of the other component). When I go to the registry key name corresponding to EventPackage.IEventListener, I find that there is no \TypeLib subkey. As you might suspect, searching the reg for "0D76C094-21A6-4E04-802B-6E539F7102D7" yields no results.

所以我知道这一定是注册表问题,但我似乎尝试了我找到的所有谷歌结果.我试过 Regasm 和 regsvcs .exe 无济于事.很多页面只是告诉我,将dll拖到COM+管理器中应该会自动注册组件.

So I know this must be a registry problem, But I have tried seemingly every google result I have found. I have tried Regasm and regsvcs .exe's to no avail. Many pages just tell me that dragging the dll to the COM+ manager should automatically register the component.

那么如何注册类型库?

  1. 运行 VB6->VB.NET 向导

然后我在 assemblyinfo.vb 文件中添加了一些行

Then I added some lines to the assemblyinfo.vb file

  1. 添加了 Imports System.EnterpriseServices
  2. 添加了 Imports System.EnterpriseServices
  3. 导入 System.Data.SqlClient
  4. <程序集:CLSCompliant(True)>
  5. 用于强名称
  6. (其中..."是旧组件的 COM+ CLSID)
  1. added Imports System.EnterpriseServices
  2. added Imports System.EnterpriseServices
  3. Imports System.Data.SqlClient
  4. <Assembly: CLSCompliant(True)>
  5. <Assembly: AssemblyKeyFileAttribute("...")> for a strong name
  6. <Assembly: Guid("...")> (Where "..." is the COM+ CLSID of the old component)

我在类文件 IEventListener.VB 中添加了以下内容

I added the following to the class file IEventListener.VB

  1. 导入 System.EnterpriseServices
  2. _(其中 ... 是正确的 COM+ CLSID,这是唯一的参数)
  3. 继承ServicedComponent
  4. 将转换向导生成的 ID 更改为正确的值(从 _
  1. Imports System.EnterpriseServices
  2. <ComClass("...")> _ (Where ... is the proper COM+ CLSID, that is the only argument)
  3. Inherits ServicedComponent
  4. changed the ID made by the Conversion wizard to the proper value (from <System.Runtime.InteropServices.ProgId("IEventListener_NET.IEventListener)> to <System.Runtime.InteropServices.ProgId("EventPackage.IEventListener")> _

然后我将 DLL 拖到适当的 COM+ 应用程序中的 COM+ 管理器中(尽管未指定路径",仅显示 mscoree.dll)

Then I dragged the DLL into the COM+ manager in the proper COM+ application (although, the "Path" is not specified and only says mscoree.dll)

推荐答案

我认为这里的问题是您没有为 .NET 组件生成类型库.我知道你说过你使用过 regasm - 但你使用了正确的命令行吗?

I think that the problem here is that you haven't generated a type library for your .NET component. I know you said you used regasm - but did you use the right command line?

  • 开始菜单 => 程序 => Microsoft .NET Framework SDK vX.Y => SDK 命令提示符.
  • 在此命令行中,键入:regasm/tlb:Mydll.dll
  • Start Menu => Programs => Microsoft .NET Framework SDK vX.Y => SDK Command Prompt.
  • In this command line line, type: regasm /tlb:Mydll.dll

这篇关于如何正确注册 VB.NET COM+ 组件的类型库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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