VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug VB6 ActiveX DLL

16 REPLIES 16
Reply
Message 1 of 17
Anonymous
1914 Views, 16 Replies

Debug VB6 ActiveX DLL

Greetings,

First of all I want to note that I've scoured the existing posts in the various discussion forums for search terms like "debug", "vb6", and "dll", with some promising leads, but none have seemed to help. Please help!!

I have a VB6 ActiveX dll which is used by AutoCAD. I would like to set a breakpoint and step through/debug the code. Nothing I have tried seems to work (the breakpoints are never hit, even though I know the dll is being run).

I have tried the following with no success:

1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Wait for components to be created" radio button
4. Set the make properties for the dll project to build the dll in the folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging
6. Start AutoCAD and test

Additionally I have tried:
1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Start program" radio button and set path to AutoCAD exe
4. Set the make properties for the dll project to build the dll in the folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging

Neither has worked. I can't believe I'm the only person who has tried to do this, so any pointers would be GREATLY appreciated.

Thanks in advance.
16 REPLIES 16
Message 2 of 17
Anonymous
in reply to: Anonymous

Debugging interpreted VBA, over the web, is hard enuff... Im going to have to see at least some snippets I can trace thru ...

but a first question ... did this code run previously, but suddenly stop?
Message 3 of 17
Anonymous
in reply to: Anonymous

Hi rocheey,

Well it's VB6, not VBA - if that makes a difference. And the code works fine (or as fine as decade-old code can work!)... it's just that there are some feature requests the customer is making and being able to set a breakpoint and step through/debug would be extremely useful. So code snippets won't really help in this case. I just need to find out how to attach the AutoCAD process to the VB6 dll for debugging purposes....
Message 4 of 17
Anonymous
in reply to: Anonymous

Im aware you said it was a VB6 dll; and Im aware it makes a difference, having written many myself.

But again, even when someone here posts a generic VBA problem, you'll hear the same chant: post the code.
Message 5 of 17
Anonymous
in reply to: Anonymous

Alright... I guess i'll post a button click event (there's thousands of lines of code in 50 or so different *.frm and *.bas files, so I can't post them all, let me know if you'd prefer some other snippet. This is just an example):

Private Sub btnOk_Click()

UpdateFPOCFlowData

End Sub

When I tried both debugging techniques above, and put a breakpoint on UpdateFPOCFlowData, it doesn't trigger the breakpoint. The click event is still firing though.

Does anyone know how to hook up VB6 dll debugging in AutoCAD? Message was edited by: cgoldfarb
Message 6 of 17
Anonymous
in reply to: Anonymous

make sure that the output directory for the dll is correct
if 2 dlls exist acad may not be using your output dll

wrote in message news:5981049@discussion.autodesk.com...
Greetings,

First of all I want to note that I've scoured the existing posts in the
various discussion forums for search terms like "debug", "vb6", and "dll",
with some promising leads, but none have seemed to help. Please help!!

I have a VB6 ActiveX dll which is used by AutoCAD. I would like to set a
breakpoint and step through/debug the code. Nothing I have tried seems to
work (the breakpoints are never hit, even though I know the dll is being
run).

I have tried the following with no success:

1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Wait for components to be created" radio button
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging
6. Start AutoCAD and test

Additionally I have tried:
1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Start program" radio button and set path to AutoCAD exe
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging

Neither has worked. I can't believe I'm the only person who has tried to do
this, so any pointers would be GREATLY appreciated.

Thanks in advance.
Message 7 of 17
Anonymous
in reply to: Anonymous

Debugging VB DLL used inside Acad VBA code is a bit tricky, but still simple
enough to do. Do the following steps:

1. Create your ActiveX DLL project in VB6. Complete your classes.
2. Inthe DLL project's properties window, "Debugging"tab, choose "Start
program" and point it to [Acad installation path]\acad.exe
3. Compile the DLL file;
4. Start AutoCAD and load your VBA, make sure the VBA project has reference
to to the DLL.

Note, you probably have already above 4 steps done.

5. Make sure AutoCAD is closed.
6. In VB6 IDE, hit F5 to start debugging, which launches Acad
7. Load your VBA project into Acad
8. Now you can set break point either in Acad VBA code or in VB6 DLL code
9. Run macro/form in the VBA project, which calls code in DLL with break
point set.

Now, the break point will be hit as long as your code logic says so. Then
you can step line by line thereafter.



"cgoldfarb" wrote in message news:5981049@discussion.autodesk.com...
Greetings,

First of all I want to note that I've scoured the existing posts in the
various discussion forums for search terms like "debug", "vb6", and "dll",
with some promising leads, but none have seemed to help. Please help!!

I have a VB6 ActiveX dll which is used by AutoCAD. I would like to set a
breakpoint and step through/debug the code. Nothing I have tried seems to
work (the breakpoints are never hit, even though I know the dll is being
run).

I have tried the following with no success:

1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Wait for components to be created" radio button
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging
6. Start AutoCAD and test

Additionally I have tried:
1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Start program" radio button and set path to AutoCAD exe
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging

Neither has worked. I can't believe I'm the only person who has tried to do
this, so any pointers would be GREATLY appreciated.

Thanks in advance.
Message 8 of 17
Anonymous
in reply to: Anonymous

Thanks all. Unfortunately this didn't work - the breakpoint isn't getting hit. I know the code itself is being run (and I've tried placing breakpoints in a number of different forms and methods, so I've ruled out that the code itself may not be getting run). I've verified that acad is using the dll I'm debugging (I put some old-style messageboxes in to confirm this). Something is just not right. Frustrating!

Anyway thanks again to everyone for your input and help. I don't know what might be wrong.
Message 9 of 17
Anonymous
in reply to: Anonymous

don't know what you mean by dll which is used by AutoCad
I doubt acad is using Your dll

generally you have a dll and an exe
your exe uses your dll in acad's process space via GetInterfaceObject (or
out of process...not recommended...via CreateObject or New)

is that what you mean?
if so, you have an exe vb6 project and a vb6 dll project
one way: create a project group with both the exe and the dll in it and you
can debug to your hearts content
:-)
hth
mark

wrote in message news:5981049@discussion.autodesk.com...
Greetings,

First of all I want to note that I've scoured the existing posts in the
various discussion forums for search terms like "debug", "vb6", and "dll",
with some promising leads, but none have seemed to help. Please help!!

I have a VB6 ActiveX dll which is used by AutoCAD. I would like to set a
breakpoint and step through/debug the code. Nothing I have tried seems to
work (the breakpoints are never hit, even though I know the dll is being
run).

I have tried the following with no success:

1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Wait for components to be created" radio button
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging
6. Start AutoCAD and test

Additionally I have tried:
1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Start program" radio button and set path to AutoCAD exe
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging

Neither has worked. I can't believe I'm the only person who has tried to do
this, so any pointers would be GREATLY appreciated.

Thanks in advance.
Message 10 of 17
Anonymous
in reply to: Anonymous

what do you mean by your dll is used by AutoCad?
How do you "start" your program?
Through a vb6.exe? or through a vba macro?

The only way I've used a dll in acad is to have a dll and an exe
The exe uses the dll in acad's process space via GetInterfaceObject

is that what you mean?
if so, you have a vb6 exe project and a vb6 dll project?
if that's the case, create a project group with both the exe and the dll in
it and you
can debug to your hearts content
:-)
hth
mark

wrote in message news:5981049@discussion.autodesk.com...
Greetings,

First of all I want to note that I've scoured the existing posts in the
various discussion forums for search terms like "debug", "vb6", and "dll",
with some promising leads, but none have seemed to help. Please help!!

I have a VB6 ActiveX dll which is used by AutoCAD. I would like to set a
breakpoint and step through/debug the code. Nothing I have tried seems to
work (the breakpoints are never hit, even though I know the dll is being
run).

I have tried the following with no success:

1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Wait for components to be created" radio button
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging
6. Start AutoCAD and test

Additionally I have tried:
1. Right-click on the VB dll project
2. Click "Debugging" tab
3. Click "Start program" radio button and set path to AutoCAD exe
4. Set the make properties for the dll project to build the dll in the
folder that AutoCAD expects
5. Click the "Play" button in the Visual Basic IDE to kick off debugging

Neither has worked. I can't believe I'm the only person who has tried to do
this, so any pointers would be GREATLY appreciated.

Thanks in advance.
Message 11 of 17
Anonymous
in reply to: Anonymous

oops sorry for the double post, this didn't go through first time so revised
and resent

"MP" wrote in message
news:5981966@discussion.autodesk.com...
don't know what you mean by dll which is used by AutoCad
I doubt acad is using Your dll

.
Message 12 of 17
Anonymous
in reply to: Anonymous

Aha MP, we might be getting closer to the root of the problem.

I have been on this project literally a week and have zero AutoCAD experience prior, so apologies for the confusion.

You're right, AutoCAD doesn't use my dll. Basically there are these extensions baked into AutoCAD from a company called "Bentley". They have things like "Plant XM" and "Redline" and other tools which are intended to add manufacturing-related capabilities to AutoCAD. It's these Bentley extensions that use my dll. The Bentley suite is ginormous and I'm not really sure where my dll is being instantiated by Bentley.

I guess I could create a dummy VB6 exe that calls my dll and debug that way, but it wouldn't really help as I need that AutoCAD drawing context for the debugging to make sense.
Message 13 of 17
Anonymous
in reply to: Anonymous

Well if Bentley code is the one using your dll, don't you need the bentley
source to do your debugging?
especially if you're adding methods/properties, the calling code would need
to be updated wouldn't it?
assuming you have the bentley source wouldn't you debug in whatever language
ide that's in ? (probably not vb6)

If you don't have the bentley code, but you can create an exe that calls
your dll, you can just set a reference to acad, create an instance, create
your dll in process, and you would then have that context for the
debugging...

???
hth
mark

wrote in message news:5981979@discussion.autodesk.com...
Aha MP, we might be getting closer to the root of the problem.

I have been on this project literally a week and have zero AutoCAD
experience prior, so apologies for the confusion.

You're right, AutoCAD doesn't use my dll. Basically there are these
extensions baked into AutoCAD from a company called "Bentley". They have
things like "Plant XM" and "Redline" and other tools which are intended to
add manufacturing-related capabilities to AutoCAD. It's these Bentley
extensions that use my dll. The Bentley suite is ginormous and I'm not
really sure where my dll is being instantiated by Bentley.

I guess I could create a dummy VB6 exe that calls my dll and debug that way,
but it wouldn't really help as I need that AutoCAD drawing context for the
debugging to make sense.
Message 14 of 17
Anonymous
in reply to: Anonymous

> Well if Bentley code is the one using your dll, don't you
> need the bentley source to do your debugging?

I see your point. The way it's set up is that my company works with Bentley for this customization. Bentley provides the extensions to AutoCAD and they have the calls in their code to initialize our dll. So I don't really have their code per se.

> especially if you're adding methods/properties, the calling
> code would need to be updated wouldn't it?

Another good point, but it's more like this: the Bentley extensions say "load and show formA". formA is a form in my application, but Bentley doesn't own it. So I need to update formA, such as adding new fields which are inserted into a database.

> If you don't have the bentley code, but you can create
> an exe that calls your dll, you can just set a reference to
> acad, create an instance, create your dll in process, and
> you would then have that context for the debugging...

This sounds a little twisted (in a good way)... I'll try this out.

Mark, thanks again. I owe you a virtual beer.
Message 15 of 17
Anonymous
in reply to: Anonymous

Curiously, how Bentley extensions could use your code? Do you own their code
so that you can modify and re-compile in order for Bentley extensions use
you ActiveX DLL?

If you really do is having some your Acad VBA code that calls Bentley's DLL
and your DLL, or even your DLL has reference to Bentley extensions, then
your DLL is used in Acad. I really doubt your DLL can be instantiated inside
Bentley extensions without recompile their code. I also assume the bentley
extensions yu ae talking is acad addin (thus "extensions"), which run inside
Acad, not a stand-alone application, otherwise, you would not talking Acad
debugging here, right? You may want to describe your situation a bit more.
Anyways, debugging ActiveX DLL is a bit tricky, comparing to exe, you need
to run the code in an EXE app (such as Acad) to debug. As long as you know
where your code in run and the correct EXE is launched by VB6 bt hitting F5,
there should not have much difficulties to get the break point.

"cgoldfarb" wrote in message news:5981979@discussion.autodesk.com...
Aha MP, we might be getting closer to the root of the problem.

I have been on this project literally a week and have zero AutoCAD
experience prior, so apologies for the confusion.

You're right, AutoCAD doesn't use my dll. Basically there are these
extensions baked into AutoCAD from a company called "Bentley". They have
things like "Plant XM" and "Redline" and other tools which are intended to
add manufacturing-related capabilities to AutoCAD. It's these Bentley
extensions that use my dll. The Bentley suite is ginormous and I'm not
really sure where my dll is being instantiated by Bentley.

I guess I could create a dummy VB6 exe that calls my dll and debug that way,
but it wouldn't really help as I need that AutoCAD drawing context for the
debugging to make sense.
Message 16 of 17
Anonymous
in reply to: Anonymous

> Curiously, how Bentley extensions could use your
> code? Do you own their code so that you can modify
> and re-compile in order for Bentley extensions use
> you ActiveX DLL?

Basically all I need to do is make sure that my dll is in a specific folder that the Bentley suite expects it to be. Just updating the dll in that folder allows the latest changes to my dll to be reflected in AutoCAD.

> If you really do is having some your Acad VBA code
> that calls Bentley's DLL and your DLL, or even your
> DLL has reference to Bentley extensions, then
> your DLL is used in Acad.

I'm not entirely sure (having been on this for about a week now - and the guy I replaced is gone!) but I don't know of any VBA code that we own. I believe Bentley may have some VBA code, in fact I'm sure of it, but the Bentley suite is huge and it includes proprietary applications in addition to the AutoCAD extensions (plugins?)

> I really doubt your DLL can be instantiated inside
>Bentley extensions without recompile their code.

That may be. I hope I don't sound too stupid, but all I know is that I can make a change to the dll, copy the dll to a specific folder, and then run AutoCAD, and the changes show up in AutoCAD.

> I also assume the bentley extensions yu ae talking is acad
> addin (thus "extensions"), which run inside Acad, not a
> stand-alone application, otherwise, you would not talking
> Acad debugging here, right? You may want to describe
> your situation a bit more.

Exactly. Sorry for the confusion. Bentley does have alot of separate applications that install, but the core capabilities are extensions/plugins to AutoCAD itself, so there's things like new toolbars and menu items, that type of thing.

> Anyways, debugging ActiveX DLL is a bit tricky,
> comparing to exe, you need to run the code in an EXE
> app (such as Acad) to debug. As long as you know
> where your code in run and the correct EXE is launched
> by VB6 bt hitting F5, there should not have much
> difficulties to get the break point.

Thanks. This is what I am almost 100% sure is happening; Basically, my dll is instantiated by Bentley plugins, which run in AutoCAD. The only way I am able to see my dll forms and run my dll *.bas methods are by starting AutoCAD and running a Bentley command down at the bottom of AutoCAD (I type "CATT" in the command window, am prompted to select a component on the drawing, and -voila - my custom dll forms are displayed or my dll methods are fired.

Maybe it's this extra layer that's causing the problem with the hookup between AutoCAD exe process and the dll debugging instance.

In any case I just want to say thanks again to everyone who has responded. You guys are just awesome.
Message 17 of 17
Anonymous
in reply to: Anonymous

"cgoldfarb" wrote in message news:5982194@discussion.autodesk.com...
> Curiously, how Bentley extensions could use your
> code? Do you own their code so that you can modify
> and re-compile in order for Bentley extensions use
> you ActiveX DLL?

Basically all I need to do is make sure that my dll is in a specific folder
that the Bentley suite expects it to be. Just updating the dll in that
folder allows the latest changes to my dll to be reflected in AutoCAD.



No, ActiveX is not folder/path/location depended. a process that calls an
ActiveX DLL accoring to Windows registry, not the DLL file's location. The
ActiveX DLL has to be registered with Regsvr32.exe before it can be seen by
other application. On your development computer, when you compile the
ActiveX DLL, VB6 does the registering for you. When you deploy the DLL to
other computer, you must register it with Regsvr32.exe, while the DLL file
can be place in different folder on different computer. So, that could a a
reason that you do not know which DLL is loaded into which.



> If you really do is having some your Acad VBA code
> that calls Bentley's DLL and your DLL, or even your
> DLL has reference to Bentley extensions, then
> your DLL is used in Acad.

I'm not entirely sure (having been on this for about a week now - and the
guy I replaced is gone!) but I don't know of any VBA code that we own. I
believe Bentley may have some VBA code, in fact I'm sure of it, but the
Bentley suite is huge and it includes proprietary applications in addition
to the AutoCAD extensions (plugins?)



OK, with certain tricks, VB ActiveX DLL can be loaded into an app process
for certain location without run Regsvr32.exe in advance. Thta maybe is how
your DLL gets loaded into Bentley extensions. Are you writning yuor DLL by
implementing interfaces required by those Bentley extensions? If not, I just
could not think how the extension can use your DLL.




> I really doubt your DLL can be instantiated inside
>Bentley extensions without recompile their code.

That may be. I hope I don't sound too stupid, but all I know is that I can
make a change to the dll, copy the dll to a specific folder, and then run
AutoCAD, and the changes show up in AutoCAD.

> I also assume the bentley extensions yu ae talking is acad
> addin (thus "extensions"), which run inside Acad, not a
> stand-alone application, otherwise, you would not talking
> Acad debugging here, right? You may want to describe
> your situation a bit more.

Exactly. Sorry for the confusion. Bentley does have alot of separate
applications that install, but the core capabilities are extensions/plugins
to AutoCAD itself, so there's things like new toolbars and menu items, that
type of thing.

> Anyways, debugging ActiveX DLL is a bit tricky,
> comparing to exe, you need to run the code in an EXE
> app (such as Acad) to debug. As long as you know
> where your code in run and the correct EXE is launched
> by VB6 bt hitting F5, there should not have much
> difficulties to get the break point.

Thanks. This is what I am almost 100% sure is happening; Basically, my dll
is instantiated by Bentley plugins, which run in AutoCAD. The only way I am
able to see my dll forms and run my dll *.bas methods are by starting
AutoCAD and running a Bentley command down at the bottom of AutoCAD (I type
"CATT" in the command window, am prompted to select a component on the
drawing, and -voila - my custom dll forms are displayed or my dll methods
are fired.

Maybe it's this extra layer that's causing the problem with the hookup
between AutoCAD exe process and the dll debugging instance.

In any case I just want to say thanks again to everyone who has responded.
You guys are just awesome.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators