Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing vb ActiveX,, CreateInstance returns "Class not registered"

Status
Not open for further replies.

Maim

Programmer
Jun 25, 1999
106
0
0
CA
I'm maintaining some legacy code that doesn't seem to work correctly...

An ActiveX dll was created a while ago in VB6 to process some data in the database. This dll is imported into a VC++ (visual studio .net 2003) project with the #import directive, but when it attempts to create an instance of this (CreateInstance smart-pointer), it always returns a null. While debugging into the CreateProcess (comip.h), CoCreateInstance returns "Class not registered".

I checked the registry, the keys are correct (guid, InprocServer32, ProgID), I create a separate vb6 exe, references the dll correctly.

Do I need to change the way the dll is being imported?
[tt]
CODE
----

#import "\projects\DBProcess\DBProcess.dll"

...

DBProcess::_ClassProcessPtr pDBP;

pDBP.CreateInstance("DBProcess.ClassProcess");
//pointer is null
...

[/tt]

-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook
 
try to register with regsvr32

Ion Filipski
1c.bmp
 
That's not it.

I thought that perhaps there were other of the same dlls elsewhere so I searched the HDs to delete all files (only one) I found except the one in the vb directory (binary compatibility), I ran regsvr32 /u dll, scrubbed the registry for the classes, recompiled, ran regsvr32 dll, recompiled the exe.

Problem not solved.


-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook
 
have you taken a look in registry to see if HKEY_CLASSES_ROOT\DBProcess.ClassProcess key exists? Maybe there is some DBProcess.ClassProcess.1 (or mayme it does not exist at all)?

Ion Filipski
1c.bmp
 
That's not it. The class name is correct in the registry and it has the correct Clsid (HKCR\CLSID\...)


-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook
 
in HKCR\CLSID are written GUID's, not prog id's. But when you are creating the instance like this:
pDBP.CreateInstance("DBProcess.ClassProcess"); you are using the ProgID's, not GUID. This "DBProcess.ClassProcess" is a ProgID. And it is written in just in HKCR , not in HKCR\CLSID

Ion Filipski
1c.bmp
 
IonFilipski, thanks for all your suggestions but I figured out what was failing after having the olap guru check the references in the vb dll.

Seems this dll calls SQLDMO (for olap processing) by CreateObject rather than a reference so the linking fails at runtime because I don't have those tools installed on my debug env...

ugh...


-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top