Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

register COM type library in registry

Posted on 2014-02-15
9
Medium Priority
?
681 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 750 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 750 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 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