Saturday, December 06, 2008

Debugging an activex dll called from a classic asp page.....

in the Visual Basicv 6 IDE used to work so easily before all the security updates from MS made it a lot harder.

I had an idea for a web app that I could run on my webserver here, but wanted the flexibility of single-stepping through my code in VB6 instead of having to put lots of response.write statements in the classic asp code.

Basically, calling an ActiveX DLL requires the following code in the asp page:

<%

Dim oObject

Set oObject = Server.CreateObject("Project1.Class1")

Response.Write oObject.DoSomething

Set oObject = nothing

%>

That's all the asp page needs to be - the rest of the code is in the Class1 module of the Project1 project. All fine so far.

So anyway, to be able to actually debug in the VB6 IDE, you need to follow the instructions here:

But I still couldn't get it to work. Here's my solution:

Put a breakpoint on a line of code in your AxDLL.

Start your project (Ctrl-F5)

Start Regedit.

Find the Project1.Class1 key in HKLM\Software\Classes

Right click it.

Select Permissions.

Click Add.

Type "everyone" (the everyone group)

Click Ok.

Select the Everyone entry.

Click the Allow checkbox to the right of the Full Control label.

Click Ok.

Browse to the asp file in a web browser.
With any luck, the VB6 IDE will now be active and you can step through the code.

Press F5 to continue running and return the result back to the asp page.

You should see your results.

Now, stop your project.

Refresh the RegEdit page.

See how the Project1.Class1 entry has disappeared? Bummer isn't it? You'll have to go through the process of granting Everyone Full Control each and every time you run your AxDLL project, but hey, its a small price to pay to get it to break in the IDE from your asp page.

Hope this helps someone, somewhere.

Oh! And by the way, this is only meant for development on your local machine. Once you've got the AxDLL finalised, you can then compile and register it for real on your web server machine. Once you've done that, you'll need to give full rights to the HKLM\Software\Classes Project1.Class1 key to IUSR_???? and the NETWORK service - I think. Please correct me if I'm wrong.



Reblog this post [with Zemanta]

1 comment:

Jeff V said...

I'm having an issue where I need to have a registered .dll in the directory where my site is, however, when I have this dll it doesn't break into the code. If I pull out the .dll (delete/unregister) the site doesn't work (error creating object).

Any ideas?