Solved

register COM type library in registry

Posted on 2014-02-15
9
651 Views
Last Modified: 2014-02-18
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
0
Comment
Question by:kolibree53
  • 6
  • 2
9 Comments
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 250 total points
ID: 39862838
Your wording is a little confusing so I want to be clear about this. The dll is trying to communicate with your .NET application via COM, not the other way around. Is that correct?

If that's the case, you'll need to make your .NET application COM-callable. Here are a couple of articles that explain how to do that.

http://www.codeproject.com/Articles/3511/Exposing-NET-Components-to-COM

https://www.simple-talk.com/dotnet/visual-studio/build-and-deploy-a-.net-com-assembly/
0
 

Author Comment

by:kolibree53
ID: 39862921
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
0
 
LVL 16

Assisted Solution

by:hjgode
hjgode earned 250 total points
ID: 39864002
OK, as far as I understand, the VB6 app did expose a COM interface in the registry which is used by a DLL to communicate with. But which process refs the DLL?

You can expose a .NET library to COM, see http://blog.functionalfun.net/2010/05/primer-on-exposing-net-to-com.html. But AFAIK you cannot expose a .NET driectly to COM. So write a DLL (a .net library) that exposes a COM interface for the DLL and some communication code for use in your .NET application. Then import/reference the library in your .NET app.

DLL <--> .NET COM library <--> .NET application
 ^---------------------------------------------^

If you need more help we need to know more details, in example what the DLL does and what role the COM object has.
0
 

Author Comment

by:kolibree53
ID: 39865011
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:kolibree53
ID: 39865025
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
0
 
LVL 16

Expert Comment

by:hjgode
ID: 39865421
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.
0
 

Author Comment

by:kolibree53
ID: 39865452
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.
0
 

Author Comment

by:kolibree53
ID: 39865474
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

0
 

Author Comment

by:kolibree53
ID: 39868185
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
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now