VB6 Activex component can't create object

user2433108 picture user2433108 · Jun 25, 2013 · Viewed 26.1k times · Source

I am making a few minor updates to a VB6 application. It runs on a windows 2000 server connected to a SQL Server 2000 Database.

I took a copy of the source code from the server updated it and complied it locally. My local machine is running windows 7 64x. I copied the .exe file back to the server and when I tried to run it I received the runtime error 49: Activex component can't create object. I know this error occurs when the application tries to open a connection to the database using RDO.

I can run the .exe fine from my local machine and my virtual pc which is running windows xp.

This application was previously working on the server and the changes I made were to the contents of a file it outputs so no new references would be needed.

These are the lines it is falling over on:

rdoEnvironments(0).CursorDriver = rdUseNone 
Set conDB = rdoEnvironments(0).OpenConnection("MRA", rdDriverNoPrompt, True) 

Answer

Winter Dragoness picture Winter Dragoness · Mar 27, 2015

I recently resolved the Activex component can't create object error as follows:

  • Open your .vbp file for your VB6 project in a text editor.
  • At the top of the file will be all the activex objects the project uses. In my case, these were:

    Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
    Object={22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0; msdxm.ocx
    Reference=*\G{3F4DACA7-160D-11D2-A8E9-00104B365C9F}#5.5#0#C:\WINDOWS\system32\vbscript.dll\3#Microsoft VBScript Regular Expressions 5.5
    Reference=*\G{3D0758FA-4171-11D0-A747-00A0C91110C3}#a.0#0#C:\WINDOWS\system32\dbgwproc.dll#Debug Object for AddressOf Subclassing
    Object={248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0; MSWINSCK.OCX
    Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.ocx
    Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX
    Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0; RICHTX32.OCX
    
  • Open regedit app.

  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Classes
  • Ctrl+F, then search for each class id above, such as {00020430-0000-0000-C000-000000000046}
  • Expect to find Reference= entries in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface and Object= entries in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID
  • After each entry you'll notice there's a version like #1.2. In my case I found the same version number listed in a Version key near where I found a match in the registry. If the versions don't match, it may be worth registering the OCX or DLL file of the correct version.
  • After finding each entry, you can click in the regedit tree and hit left arrow till you get back to the Classes branch, then search for the next entry.
  • Most importantly, if you don't find an entry for the class id you searched for, that is most likely causing the Activex component can't create object error.

In my case, the missing class was Reference=*\G{3D0758FA-4171-11D0-A747-00A0C91110C3}#a.0#0#C:\WINDOWS\system32\dbgwproc.dll#Debug Object for AddressOf Subclassing. This is a special class used when running VB6 apps in the debugger but it should not be distributed with the app or referenced in apps that are distributed. I got VB to stop referencing dbgwproc.dll by opening Project > <app name> Properties... > 'Make' tab and deleting DEBUGWINDOWPROC = 1 from Conditional Compilation Arguments:. After rebuilding, no more error occurred.