RunninThruLife
RunninThruLife

Reputation: 69

VB6 program interacting with AutoCAD, is not longer able to create, or bind to the ACAD object

Stack,

To start, this website is fantastic, you've helped me through a lot of issues in the past; thanks.

Moving forward, this program has been in existence, and in use, since AutoCAD 2000. The current version of the software is compatible up to ACAD 2017.

I work with a small team, and out of nowhere, my PC is struggling with the VB6/AutoCAD combination; the other developers are still working with no issues...

Late binding is used to get, or create, the object; depending on whether Acad is already running... e.g.

Set oAutoCad = GetObject(, "Autocad.Application")
If err.Number Then
    err.Clear
    Set oAutoCad = CreateObject("Autocad.Application")
    If err.Number Then
        MsgBox UCase$("Unable to launch AutoCAD Session")
        End
    Else
        oAutoCad.Visible = True
    End If
End If

There are two different executables (using the same binding technique) that work with ACAD to do different things. For both of them, the software fails on both CreateObject and GetObject with "Run Time Error 429 - ActiveX Component Cannot Create Object. However, adding '.20' to the call allows me to create an object, but I still can't bind to an existing. e.g...

Call CreateObject("Autocad.Application.20")

I believe the difference between myself and the team is that I recently had to re-install VB6 after some 'Error Accessing Registry' issues surfaced (immediately after a Windows update...weird). That's the big difference; everyone else has migrated from 7 to 10 with VB6 installed. I'm the first one to install on a windows 10 machine directly.

We were originally using SP6 with VB6, though this issue has brought some things to my attention. Apparently, they are still updating the service pack. So, the computer has recently been updated to SP6D. I've also tried installing the Cumulative Service Pack.

I've attempted to change the compatibility settings from Win 7, Win 8, XP's (all of them)... I have no idea.

I've run as administrator

It's a 64 bit machine.

The original VB6 MSDN library has been installed... for some reason, the SP6 wouldn't install correctly until it was... for that matter, that actual VB6 installation gets hung up on the end. It doesn't appear to affect much, but it must be doing something in the background (or not doing)

Any help would be greatly appreciated... here's to hoping.

******* New Information ******* Apparently, adding the '.20' is only good enough for one of the exes, the other requires and additional version number (e.g. "Autocad.Application.20.1")

To make it more interesting, if I start the project with the '20.1', stop the code the moment the object is created, wait for autocad to launch, set it to visible, open the drawing I need to connect to using the ACAD UI, then allow the program to continue, GetObject doesn't fail...

????

Upvotes: 1

Views: 1524

Answers (1)

RunninThruLife
RunninThruLife

Reputation: 69

After what seemed like an eternity of searching, I found the answer here...

Late binding run-time error in VB6 when creating an object from a .NET assembly

The gist of it was this...

When using CreateObject/GetObject the Class ID (CLSID) that your invoking is stored in the registry... both under the HKEY_CLASSES_ROOT hive and the HKEY_LOCAL_MACHINE hive under (Classes)-(AutoCAD.Application)(.X)

It seems that the CreateObject call uses the HKEY_CLASSES_ROOT, while GetObject may be using the HKEY_LOCAL_MACHINE... of that I'm not sure, but it would explain why the CreateObject call was working and not the GetObject. My HKEY_LOCAL_MACHINE hive was somehow missing the 'AutoCAD.Application' key; possibly due to an un-install or an update of some kind... I'm not sure.

What I do know is by comparing the values between the hives and adding the 'CurVer' value and the 'CLSID' value to a newly created 'AutoCAD.Application' key, the program is now able to create and bind without specifying a version (e.g...

CreateObject("AutoCAD.Application")
GetObject(, "AutoCAD.Application")

instead of...

CreateObject("AutoCAD.Application.20.1")
GetObject(, "AutoCAD.Application.20")

or even worse

Run-Time Error 429: ActiveX Component Cannot Create Object

Thanks again Stack.

Upvotes: 0

Related Questions