Link to home
Start Free TrialLog in
Avatar of kolibree53
kolibree53

asked on

register COM type library in registry

Hi,

I'm working on an open project I found on sourceforge.net called BCR2000control.

This project has two components to it.
1. A surface control .dll which will implement into a DAW like Cakewalks Sonar and is written in C++.
2. A Windows program acting as a hardware console which the above .dll is communicating with and the source code is in VB6.

I converted the windows source from VB6 to VB.net 2005 and the program is running.
The problem is, that this newly created exe can not be found by the .dll because it does not create any entries in the registry.

When I run the exe file which came with the original project it will install registry entries with TypeLib information.

My version made in .net does not create any such entries, so the dll can't hook into it.

Any thoughts on how to do this?

Thanks,
Dirk
ASKER CERTIFIED SOLUTION
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kolibree53
kolibree53

ASKER

Hi Craig,
This is a new area in programming for me. That's why I probably use the wrong terms in explaining my problem.
I did look into your links and found a couple of others links about this subject but still have a hard time wrapping my head around it.

The two parts as I understand it.

1. The .dll part which is called from the host Sonar
This .dll is trying to find the "Console" app in the registry via

 "CONSOLE_PROGID L"prjBCR2000Console.CBCR2000Console"

with a consequent:

// get COM object
            hr = CoCreateInstance( clsid,
                                 NULL,
                                 CLSCTX_SERVER,
                                 IID_IUnknown,
                                 (void**) &pUnk);

This fails because there is no "prjBCR2000Console.CBCR2000Console" in the registry.

This entry in the registry has to be done by the the "Console" app which I converted from a VB6 to a VB.net project.

2. The console app, as I understand it, has to implement a .tlb file created during compilation of the .dll file so it knows how to communicate with the .dll.
Is that correct?
How would I do this implementation of that .tlb file and what code on the "Console" side is necessary to make them talk to each other?

Thanks,
Dirk
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi hjgode,

One of Craigs Links has an example which makes totally sense.
The .dll exposes a class to the registry by registering it with its type library by using regasm.
Then I can call the classes from another app by simply adding the .dll as a reference to this app.

In my case it seems that the .dll is registered with regsvr32 without the tlb file.
Therefore there are no registry entries coming from the .dll.

Only with executing the original EXE from the open source project the registry will get the correct COM entries.

With the re-compiled original source in VB6 my EXE does not enter the registry entries.

 Here IMO the important part of the VB6 which should do the entries.

Type=OleExe
Form=frmBCRConsole.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\WINNT\System32\stdole2.tlb#OLE Automation
Class=CBCR2000Console; CBCR2000Console.cls
Module=modMain; modMain.bas
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.ocx
Form=frmResources.frm
IconForm="frmBCRConsole"
Startup="(None)"
HelpFile=""
Title="prjBCR2000Console"
ExeName32="prjbcr2000console.exe"
Command32=""
Name="prjBCR2000Console"
HelpContextID="0"
CompatibleMode="0"
CompatibleEXE32="prjBCR2000Console.exe"
MajorVer=1
MinorVer=1
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="."
VersionFileDescription="Console Version 1.1.0"
CompilationType=-1
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=1
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
DebugStartupOption=0

What I realized later was that my VB6 does not accept the  first line Type=OleExe.
It changes it to Type=Exe. Maybe that,s where the issue is.

Thanks,
Dirk
Forgot another thing.

The last comment would deal just with the VB6 App.

My ultimate goal was to translate this VB6 COM registration in the registry into a .net version.

Dirk
In my case it seems that the .dll is registered with regsvr32 without the tlb file.
Therefore there are no registry entries coming from the .dll.

You can always register a DLL that exposes the correct interface using regsvr or regsvr32.

Back to .NET: Did you write the library? Does it expose its interface to the registry? If so, you just have to mimic the original interface or the one the app needs.

Writing the registry manually is also a solution, if the entries match the DLL or the COM object.
I did not write the DLL but I did changes to it to customize it to my needs.

No, the DLL does not expose its interface to the registry. That's what gets me.

The EXE app actually seem to have to do it. That's where my problem is.
The above VB6 code must have something to do with it. But as I said when I compile the EXE and run it, it does not expose the interface to the registry. The original one from the open source project does!
I know this because I manually deleted all references in the registry and only when I run the original VB6 EXE they are re-introduced.
One more.

Even when I run the original VB6 EXE to expose the interface to the registry and then try to run my own compiled version, the DLL can't find it whereas the original VB6 EXE will be found by the DLL.

The DLL trys to find the EXE by:

 "CONSOLE_PROGID L"prjBCR2000Console.CBCR2000Console"

with a consequent:

// get COM object
            hr = CoCreateInstance( clsid,
                                 NULL,
                                 CLSCTX_SERVER,
                                 IID_IUnknown,
                                 (void**) &pUnk);

Open in new window

It seems to me that we are stuck with this question.

Therefore I will let the VB6 portion go and open up a new question targeting the .net portion of my question.


Since I learned a lot of both commentators I will split the points between them.

Thanks,
Dirk