2
votes

I am debugging this Active X dll using the VB6 IDE. I can see the execution get as far as an attempt to GetObjectContext. This method always returns NOTHING.

This is happening on Windows 7 32 bit, IIS 7. (The application is working in other locations, one of which is Windows Server 2008 with IIS 7)

I have Googled extensively and found many references to this relating to COM+, but there is NO COM+ involved in my scenario. Just plain old Server.CreateObject from a registered dll.

I have ASP code as follows

SET objCalendar = Server.CreateObject("SSYSDEV.Calendar")
objCalendar.BuildCalendar("ADMINUSERS")
SET objCalendar = Nothing

The problem lines of the requested function in the dll are:

Dim objHttpRequest As ASPTypeLibrary.Request
Set objHttpRequest = GetObjectContext.Item("Request")

Any help or suggestions, as always, will be greatly appreciated.

I'm still getting over the shock of having to work with VB6 - I never thought it would happen! It's like being dragged back to the dark ages, in a very rough fashion that's causing blisters!

P.S. I have also set up a COM+ component and had the ASP get the object that way, GetObjectContext returns an empty object in this case, which has no ASP objects in it. So this is no help :-(

2
I have found that the behaviour described above is due to COM+ behaving differently in debug than it does otherwise. In debug, it will always return a dummy context - that has no useful objects in it. AnthonyWJones's solution below is not affected by this limitation and solves the problem perfectly.RobD

2 Answers

2
votes

I've found that the COM+ approach to using VB6 components in IIS to be a bit flaky. I add this to a VB6 class that I want to instance in ASP::-

Private moScriptCtx As ScriptingContext

Public Sub OnStartPage(SC As ScriptingContext)

    Set moScriptCtx = SC

End Sub

You can now access Request,Response,Server etc as properties of the moScriptCtx object.

You might be wondering how you call OnStartPage in the first place. You don't ASP automagically does that for you during the CreateObject execution.

2
votes

I know this is a little late, but I had a similar problem and this solved it for me:

Thread: Problem accessing Request object via COM+

http://forums.iis.net/t/1146404.aspx

Summary: turn on 'Allow IIS Intrinsic Properties' in the COM+ component.