473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Cannot pass Request object to VB COM DLL (cross post)

ON Win 2003 IIS6,
Since yesterday, (12 Aug 2003) for some strange reason, (after installing
WindowsServer2003-KB823980-x86-ENU.exe)

I cannot pass the
Request object to to VB COM DLL.

I have a funciton inVB DLL
Function BuildSqlWhereFromHTML(ByRef AspReq As ASPTypeLibrary.Request, _
ByRef AspSes As ASPTypeLibrary.Session) As String

end function

IN asp I call it with
Dim oASP
set oASP = Server.CreateObject("dllName.className")
Response.Write oASP.BuildSqlWhereFromHTML(Request, Session)

This use to work all the time. I have been uysing this for 3 years (W2K and
now W2003)

The only thing I did was to install this patch:
WindowsServer2003-KB823980-x86-ENU.exe
for the Blaster worm...

Could that affect it?

Thanks

Gerhard

Jul 19 '05 #1
4 11560
>I have a funciton inVB DLL
Function BuildSqlWhereFromHTML(ByRef AspReq As ASPTypeLibrary.Request, _ ByRef AspSes As

ASPTypeLibrary.Session) As String

Don't access built-in objects like that. Use this instead;

----

How do I access the built-in ASP objects from VB?

When using IIS3 the only way to get a handle on the built-
in ASP objects was via the ScriptingContext. When you use
Server.CreateObject, ASP would call the OnStartPage method
of your object and pass in a ScriptingContext object.
Using that object you could then get a reference to the
built-in ASP objects.
Private objScript As ScriptingContext

Sub OnStartPage(obj As ScriptingContext)
Set objScript = obj
End Sub

Sub DoSomething()
Dim objResponse As ASPTypeLibrary.Response

Set objResponse = objScript.Response
objResponse.Write "<p>Hello World</p>"
End Sub
IIS4 and IIS5 provide this same functionality for backward
compatibility but you shouldn't use it. Instead you should
get a handle on the built-in objects using the object's
ObjectContext. Objects created in ASP are given their own
context and you can choose to hook into that context if
you want to. In your VB Object Add a reference to COM+
Services if you are using Win2k, or to MTS if you are
using Windows NT, and a reference to Microsoft Active
Server Pages Object Library. Although we are adding a
reference to MTS/COM+ you don't actually need to register
the DLL with MTS, or register it as a configured component
under Win2k. The reason being is that, under the covers,
your scripts are running in the MTS environment anyway,
we're just choosing to utilise it. If you do want to add
your component to MTS/COM+ then that is fine too. The
thing to note is that you can add the object to MTS or you
can leave it as a normal DLL, using this technique does
not restrict your deployment choices.

In our VB code the built-in ASP objects are held in the
Items collection of the ObjectContext. Getting a handle on
them is a simple matter of;
Dim objResponse As ASPTypeLibrary.Response

Set objResponse = GetObjectContext.Item("Response")
We can now use objResponse just as we would the Response
object in ASP. Below is a small demo

ContextTest1.asp
<%@ Language=VBScript %>
<HTML>
<BODY>

<%
if len(trim(Session("FullName"))) > 0 then
Response.Write "<p>I remember your name as " &
Session("FullName") & "</p>"
end if
%>

<FORM action="ContextTest2.asp" method=POST>
Surname: <input type="text" name="txtSurname"><br>
Forename: <input type="text" name="txtForename"><br>
<input type="submit" value="Submit">
</FORM>
ContextTest2.asp
<%@ Language=VBScript %>
<%
set obj = Server.CreateObject("ASPObject.ASPClass")
obj.DoStuff
set obj = nothing
%>

VB Code

Create an ActiveX DLL project called ASPObject and add a
class called ASPClass. Add a reference to MTX/COM+ and a
reference to ASP. Inside ASPClass put the following code.
Option Explicit

Public Sub DoStuff()
Dim objResponse As ASPTypeLibrary.Response
Dim objRequest As ASPTypeLibrary.Request
Dim objSession As ASPTypeLibrary.Session
Dim sSurname As String
Dim sForename As String
Dim sFullName As String

Set objResponse = GetObjectContext.Item("Response")
Set objRequest = GetObjectContext.Item("Request")
Set objSession = GetObjectContext.Item("Session")

objResponse.Write "<HTML>" & vbCrLf
objResponse.Write "<HEAD>" & vbCrLf
objResponse.Write "</HEAD>" & vbCrLf
objResponse.Write "<BODY>" & vbCrLf

sSurname = Trim(objRequest("txtSurname"))
sForename = Trim(objRequest("txtForename"))

If Len(sSurname) < 2 Then
sSurname = UCase(sSurname)
Else
sSurname = UCase(Left(sSurname, 1)) & Mid
(sSurname, 2)
End If

If Len(sForename) < 2 Then
sForename = UCase(sForename)
Else
sForename = UCase(Left(sForename, 1)) & Mid
(sForename, 2)
End If

sFullName = sForename & " " & sSurname
objSession("FullName") = sFullName
objResponse.Write "<p>Hello " & sFullName & "</p>" &
vbCrLf

If Len(Trim(objRequest.ServerVariables
("HTTP_REFERER"))) > 0 Then
objResponse.Write "<p><a href=""" &
objRequest.ServerVariables("HTTP_REFERER") & """>Back</a>"
& vbCrLf
End If

objResponse.Write "</BODY>" & vbCrLf
objResponse.Write "</HTML>"

Set objResponse = Nothing
Set objRequest = Nothing
Set objSession = Nothing

End Sub
Jul 19 '05 #2
Thanks Adrian for the example.

I did excactly that, but get the
Run-time Error '91'
Object variable or With block variable not set

Dim AspReq As ASPTypeLibrary.Request

--- > when I do this: (I am debugging the Component with VB6)
Set AspReq = COMSVCSLib.GetObjectContext.Item("Request")

I am using Win 2003 IIS6, VB6 SP5. Debugging seems to work.
References to:
COM+ (COMSVCD.DLL)
Active Server Pages Library (asp.dll)

what else am I missing (As I said, I used the first method, passing the
objects for many years)
I would prefer this method, but somthing is not gelling.

I have ssen some examples of Implements COMSVCLib and then using the
Object_Create event, but this does not work either.

Still stuck, I must be missing something simple. Or can it be IIS6 ?

Gerhard Pretorius

"Adrian Forbes - MVP" <ad****@xxxnoemailxxx.com> wrote in message
news:0c****************************@phx.gbl...
I have a funciton inVB DLL
Function BuildSqlWhereFromHTML(ByRef AspReq As

ASPTypeLibrary.Request, _
ByRef AspSes As

ASPTypeLibrary.Session) As String

Don't access built-in objects like that. Use this instead;

----

How do I access the built-in ASP objects from VB?

When using IIS3 the only way to get a handle on the built-
in ASP objects was via the ScriptingContext. When you use
Server.CreateObject, ASP would call the OnStartPage method
of your object and pass in a ScriptingContext object.
Using that object you could then get a reference to the
built-in ASP objects.
Private objScript As ScriptingContext

Sub OnStartPage(obj As ScriptingContext)
Set objScript = obj
End Sub

Sub DoSomething()
Dim objResponse As ASPTypeLibrary.Response

Set objResponse = objScript.Response
objResponse.Write "<p>Hello World</p>"
End Sub
IIS4 and IIS5 provide this same functionality for backward
compatibility but you shouldn't use it. Instead you should
get a handle on the built-in objects using the object's
ObjectContext. Objects created in ASP are given their own
context and you can choose to hook into that context if
you want to. In your VB Object Add a reference to COM+
Services if you are using Win2k, or to MTS if you are
using Windows NT, and a reference to Microsoft Active
Server Pages Object Library. Although we are adding a
reference to MTS/COM+ you don't actually need to register
the DLL with MTS, or register it as a configured component
under Win2k. The reason being is that, under the covers,
your scripts are running in the MTS environment anyway,
we're just choosing to utilise it. If you do want to add
your component to MTS/COM+ then that is fine too. The
thing to note is that you can add the object to MTS or you
can leave it as a normal DLL, using this technique does
not restrict your deployment choices.

In our VB code the built-in ASP objects are held in the
Items collection of the ObjectContext. Getting a handle on
them is a simple matter of;
Dim objResponse As ASPTypeLibrary.Response

Set objResponse = GetObjectContext.Item("Response")
We can now use objResponse just as we would the Response
object in ASP. Below is a small demo

ContextTest1.asp
<%@ Language=VBScript %>
<HTML>
<BODY>

<%
if len(trim(Session("FullName"))) > 0 then
Response.Write "<p>I remember your name as " &
Session("FullName") & "</p>"
end if
%>

<FORM action="ContextTest2.asp" method=POST>
Surname: <input type="text" name="txtSurname"><br>
Forename: <input type="text" name="txtForename"><br>
<input type="submit" value="Submit">
</FORM>
ContextTest2.asp
<%@ Language=VBScript %>
<%
set obj = Server.CreateObject("ASPObject.ASPClass")
obj.DoStuff
set obj = nothing
%>

VB Code

Create an ActiveX DLL project called ASPObject and add a
class called ASPClass. Add a reference to MTX/COM+ and a
reference to ASP. Inside ASPClass put the following code.
Option Explicit

Public Sub DoStuff()
Dim objResponse As ASPTypeLibrary.Response
Dim objRequest As ASPTypeLibrary.Request
Dim objSession As ASPTypeLibrary.Session
Dim sSurname As String
Dim sForename As String
Dim sFullName As String

Set objResponse = GetObjectContext.Item("Response")
Set objRequest = GetObjectContext.Item("Request")
Set objSession = GetObjectContext.Item("Session")

objResponse.Write "<HTML>" & vbCrLf
objResponse.Write "<HEAD>" & vbCrLf
objResponse.Write "</HEAD>" & vbCrLf
objResponse.Write "<BODY>" & vbCrLf

sSurname = Trim(objRequest("txtSurname"))
sForename = Trim(objRequest("txtForename"))

If Len(sSurname) < 2 Then
sSurname = UCase(sSurname)
Else
sSurname = UCase(Left(sSurname, 1)) & Mid
(sSurname, 2)
End If

If Len(sForename) < 2 Then
sForename = UCase(sForename)
Else
sForename = UCase(Left(sForename, 1)) & Mid
(sForename, 2)
End If

sFullName = sForename & " " & sSurname
objSession("FullName") = sFullName
objResponse.Write "<p>Hello " & sFullName & "</p>" &
vbCrLf

If Len(Trim(objRequest.ServerVariables
("HTTP_REFERER"))) > 0 Then
objResponse.Write "<p><a href=""" &
objRequest.ServerVariables("HTTP_REFERER") & """>Back</a>"
& vbCrLf
End If

objResponse.Write "</BODY>" & vbCrLf
objResponse.Write "</HTML>"

Set objResponse = Nothing
Set objRequest = Nothing
Set objSession = Nothing

End Sub

Jul 19 '05 #3
Here is the fix

Thanks to Chris Stefano... took him 2 minutes on the phone to steer me in
the right direction. And so it is:

1. Due to my stupidity, my COM+ DLLs has been running as a server
application (and not Library) which is fine... until you install the Patch
from Microsoft for the worm going around.

http://support.microsoft.com/default...b;en-us;823980

This patch changes something to the DCOM and or RPC calls, and that is where
the problem comes from.

Running the COM+ as a Library DLL changes things...

So it is....

However, what I cannot do yet, it debugging my VB DLL in VB6, because I
guess the same problem arise there. I do not know how that works, but I am
sure there is a way around. If someone can enlighten me on the setting to
enable you that it will be great.

The problem (while debugging in VB6) only arises when I pass the Request
object to the COM DLL. That is when it falls over. For other debugging it
works.

So how do I fix this?

2. Even uninstalling the Patch does not make a difference. However, I am
sure that was the problem, because that is the only thing I instaleed
related to communication between processes.

Once again thanks to Chris...top man of the day.

Regards

Gerhard

"Gerhard Pretorius" <ge*****@comprehendit.net> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
ON Win 2003 IIS6,
Since yesterday, (12 Aug 2003) for some strange reason, (after installing
WindowsServer2003-KB823980-x86-ENU.exe)

I cannot pass the
Request object to to VB COM DLL.

I have a funciton inVB DLL
Function BuildSqlWhereFromHTML(ByRef AspReq As ASPTypeLibrary.Request, _
ByRef AspSes As ASPTypeLibrary.Session) As String

end function

IN asp I call it with
Dim oASP
set oASP = Server.CreateObject("dllName.className")
Response.Write oASP.BuildSqlWhereFromHTML(Request, Session)

This use to work all the time. I have been uysing this for 3 years (W2K and now W2003)

The only thing I did was to install this patch:
WindowsServer2003-KB823980-x86-ENU.exe
for the Blaster worm...

Could that affect it?

Thanks

Gerhard

Jul 19 '05 #4
Jon
I'm glad that I'm not the only one having this problem. My vb dll's
have been running as a server app for the last 2+ years and decided to
quit once the new patch was installed. I've tried just about
everything I can think of to get this going again, but everything has
failed. I've tried turning this into a library app, but that is not
working either. The app is an asp app with vb dll's running in
component services. This is all using a SQL Server backend...pretty
standard, but now it will not run...just hangs up the asp pages. Any
fixes?

-Jon
"Gerhard Pretorius" <ge*****@comprehendit.net> wrote in message news:<uZ*************@TK2MSFTNGP12.phx.gbl>...
Here is the fix

Thanks to Chris Stefano... took him 2 minutes on the phone to steer me in
the right direction. And so it is:

1. Due to my stupidity, my COM+ DLLs has been running as a server
application (and not Library) which is fine... until you install the Patch
from Microsoft for the worm going around.

http://support.microsoft.com/default...b;en-us;823980

This patch changes something to the DCOM and or RPC calls, and that is where
the problem comes from.

Running the COM+ as a Library DLL changes things...

So it is....

However, what I cannot do yet, it debugging my VB DLL in VB6, because I
guess the same problem arise there. I do not know how that works, but I am
sure there is a way around. If someone can enlighten me on the setting to
enable you that it will be great.

The problem (while debugging in VB6) only arises when I pass the Request
object to the COM DLL. That is when it falls over. For other debugging it
works.

So how do I fix this?

2. Even uninstalling the Patch does not make a difference. However, I am
sure that was the problem, because that is the only thing I instaleed
related to communication between processes.

Once again thanks to Chris...top man of the day.

Regards

Gerhard

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
8
by: Brian F | last post by:
Exactly what the subject says. I have an ASP page that I want my C# windows application to open in Internet Explorer, and if possible have it send along a list of values from a list box. Thank you.
2
by: SMike | last post by:
I post this message again as I didn't get an answer back. I would appriciate any ideas. I am getting the following error when sending a first https request: Cannot access a disposed object...
4
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to...
1
by: R.A.M. | last post by:
Hello, I have written an .aspx page which calls Calendar.aspx page to select birth date which should be assign to some text box control on first page. Here's the code of first page: Birthdate:...
47
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to...
0
by: jianxin9 | last post by:
Hi everyone, I don't have a lot of experience with ASP and I was hoping someone could help me. I want to use our ASP form along with some javascript code to create a form where our patrons can...
2
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
when i send an xml to a server using WebRequest object (i am sending a paramater+xml in size of about 250 chars) i recve an error : System.Net.WebException was unhandled Message="The request...
3
by: Jag | last post by:
Hi I am facing a strange issue. I have 3 ASP pages in the default website 1. auth.aspx <html> <body>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.