How do I properly register the Type Library of A VB.NET COM+ Component?
Posted
by
k_Dank
on Stack Overflow
See other posts from Stack Overflow
or by k_Dank
Published on 2012-06-05T19:30:49Z
Indexed on
2012/06/07
4:40 UTC
Read the original article
Hit count: 204
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;
- Cannot load type library for reference "EventPackage". Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))
- The referenced component 'EventPackage' could not be found.
- Type 'EventPackage.IEventListener' is not defined.
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>
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.
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.
So how do I register the Type library?
Details on how I made EventPackage COM+ component
- Ran the VB6->VB.NET wizard
Then I added some lines to the assemblyinfo.vb file
- added
Imports System.EnterpriseServices
- added
Imports System.EnterpriseServices
Imports System.Data.SqlClient
<Assembly: CLSCompliant(True)>
<Assembly: AssemblyKeyFileAttribute("...")>
for a strong name<Assembly: Guid("...")>
(Where "..." is the COM+ CLSID of the old component)
I added the following to the class file IEventListener.VB
Imports System.EnterpriseServices
<ComClass("...")> _
(Where ... is the proper COM+ CLSID, that is the only argument)Inherits ServicedComponent
- 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")> _
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
)
© Stack Overflow or respective owner