Solved

register COM type library in registry

Posted on 2014-02-15
9
663 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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