Karl,
The use of OnStartPage() / OnEndPage() to access the ScriptingContext is no
longer the recommended way to access the IIS intrinsic objects in IIS 4.0
and above. Instead you should be using the GetObjectContext() method.
Debuging under VB presents a problem though because the component is being
run out of process (in VB6.exe), so the call to GetObjectContext will always
fail. To remedy this, you must use the depreciated OnStartPage() method in
your VB component and Server.CreateObject(...) in your ASP code.
Server.CreateObject passes the ScriptingContext (containing references to
the ASP Intrinsic objects) to your component via the OnStartPage(Object)
method.
So, in example:
Create a new ActiveX dll and add references to the type libraries "Microsoft
Active Server Pages Object Library" and "Com+ Services Type Library". In
the class of choice, place the following code, which use a conditional
compilation constant to include the appropriate code based on if your using
a compiled DLL or debugging from the IDE. You must change DEBUG_MODE from
True to False to use the GetObjectContext functionality when you are ready
to compile the component into a DLL:
Option Explicit
#Const DEBUG_MODE = True
#If DEBUG_MODE Then
Dim m_objScriptingContext As ScriptingContext
Public Sub OnStartPage(ScriptingContext As Object)
Set m_objScriptingContext = ScriptingContext
End Sub
Public Sub OnEndPage()
Set m_objScriptingContext = Nothing
End Sub
#End If
Public Sub WriteResponse()
Dim objResponse As Response
#If DEBUG_MODE Then
Set objResponse = m_objScriptingContext.Response
#Else
Set objResponse = GetObjectContext("Response")
#End If
objResponse.Write "<h1>Hello Karl Butcher</h1>"
Set objResponse = Nothing
End Sub
And in an ASP page use the code:
<html>
<body>
<%
Dim objASPObjects
Set objASPObjects = Server.CreateObject("KarlButcher.ASPObjects")
objASPObjects.WriteResponse()
%>
</body>
</html>
Reference (Unfortunately they are a bit out of date, but still provide
worthwhile pointers)
INFO: Design Guidelines for VB Components Under ASP
http://support.microsoft.com/support/kb/articles/Q243/5/48.ASP
ASP Component Guidelines
http://msdn.microsoft.com/workshop/server/asp/server01242000.asp
HOWTO: Obtain ObjectContext with ObjectControl Inside VB COM DLL From ASP
and MTS
http://support.microsoft.com/support/kb/articles/Q238/2/74.ASP
Quote:
> How is it possible to debug a VB DLL that is being called from an ASP page
> and is being passed a scripting context from the page ??
> Any suggestions much appreciated !!
> Regards,
> Karl Butcher
> Monsoon Malabar Limited
> www.monsoonmalabar.com