473,883 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
WindowsServer20 03-KB823980-x86-ENU.exe)

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

I have a funciton inVB DLL
Function BuildSqlWhereFr omHTML(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.CreateOb ject("dllName.c lassName")
Response.Write oASP.BuildSqlWh ereFromHTML(Req uest, 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:
WindowsServer20 03-KB823980-x86-ENU.exe
for the Blaster worm...

Could that affect it?

Thanks

Gerhard

Jul 19 '05 #1
4 11594
>I have a funciton inVB DLL
Function BuildSqlWhereFr omHTML(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 ScriptingContex t. When you use
Server.CreateOb ject, ASP would call the OnStartPage method
of your object and pass in a ScriptingContex t object.
Using that object you could then get a reference to the
built-in ASP objects.
Private objScript As ScriptingContex t

Sub OnStartPage(obj As ScriptingContex t)
Set objScript = obj
End Sub

Sub DoSomething()
Dim objResponse As ASPTypeLibrary. Response

Set objResponse = objScript.Respo nse
objResponse.Wri te "<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 = GetObjectContex t.Item("Respons e")
We can now use objResponse just as we would the Response
object in ASP. Below is a small demo

ContextTest1.as p
<%@ Language=VBScri pt %>
<HTML>
<BODY>

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

<FORM action="Context Test2.asp" method=POST>
Surname: <input type="text" name="txtSurnam e"><br>
Forename: <input type="text" name="txtForena me"><br>
<input type="submit" value="Submit">
</FORM>
ContextTest2.as p
<%@ Language=VBScri pt %>
<%
set obj = Server.CreateOb ject("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 = GetObjectContex t.Item("Respons e")
Set objRequest = GetObjectContex t.Item("Request ")
Set objSession = GetObjectContex t.Item("Session ")

objResponse.Wri te "<HTML>" & vbCrLf
objResponse.Wri te "<HEAD>" & vbCrLf
objResponse.Wri te "</HEAD>" & vbCrLf
objResponse.Wri te "<BODY>" & vbCrLf

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

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

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

sFullName = sForename & " " & sSurname
objSession("Ful lName") = sFullName
objResponse.Wri te "<p>Hello " & sFullName & "</p>" &
vbCrLf

If Len(Trim(objReq uest.ServerVari ables
("HTTP_REFERER" ))) > 0 Then
objResponse.Wri te "<p><a href=""" &
objRequest.Serv erVariables("HT TP_REFERER") & """>Back</a>"
& vbCrLf
End If

objResponse.Wri te "</BODY>" & vbCrLf
objResponse.Wri te "</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.GetO bjectContext.It em("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****@xxxnoem ailxxx.com> wrote in message
news:0c******** *************** *****@phx.gbl.. .
I have a funciton inVB DLL
Function BuildSqlWhereFr omHTML(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 ScriptingContex t. When you use
Server.CreateOb ject, ASP would call the OnStartPage method
of your object and pass in a ScriptingContex t object.
Using that object you could then get a reference to the
built-in ASP objects.
Private objScript As ScriptingContex t

Sub OnStartPage(obj As ScriptingContex t)
Set objScript = obj
End Sub

Sub DoSomething()
Dim objResponse As ASPTypeLibrary. Response

Set objResponse = objScript.Respo nse
objResponse.Wri te "<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 = GetObjectContex t.Item("Respons e")
We can now use objResponse just as we would the Response
object in ASP. Below is a small demo

ContextTest1.as p
<%@ Language=VBScri pt %>
<HTML>
<BODY>

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

<FORM action="Context Test2.asp" method=POST>
Surname: <input type="text" name="txtSurnam e"><br>
Forename: <input type="text" name="txtForena me"><br>
<input type="submit" value="Submit">
</FORM>
ContextTest2.as p
<%@ Language=VBScri pt %>
<%
set obj = Server.CreateOb ject("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 = GetObjectContex t.Item("Respons e")
Set objRequest = GetObjectContex t.Item("Request ")
Set objSession = GetObjectContex t.Item("Session ")

objResponse.Wri te "<HTML>" & vbCrLf
objResponse.Wri te "<HEAD>" & vbCrLf
objResponse.Wri te "</HEAD>" & vbCrLf
objResponse.Wri te "<BODY>" & vbCrLf

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

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

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

sFullName = sForename & " " & sSurname
objSession("Ful lName") = sFullName
objResponse.Wri te "<p>Hello " & sFullName & "</p>" &
vbCrLf

If Len(Trim(objReq uest.ServerVari ables
("HTTP_REFERER" ))) > 0 Then
objResponse.Wri te "<p><a href=""" &
objRequest.Serv erVariables("HT TP_REFERER") & """>Back</a>"
& vbCrLf
End If

objResponse.Wri te "</BODY>" & vbCrLf
objResponse.Wri te "</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*****@compre hendit.net> wrote in message
news:O8******** ******@TK2MSFTN GP10.phx.gbl...
ON Win 2003 IIS6,
Since yesterday, (12 Aug 2003) for some strange reason, (after installing
WindowsServer20 03-KB823980-x86-ENU.exe)

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

I have a funciton inVB DLL
Function BuildSqlWhereFr omHTML(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.CreateOb ject("dllName.c lassName")
Response.Write oASP.BuildSqlWh ereFromHTML(Req uest, 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:
WindowsServer20 03-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...prett y
standard, but now it will not run...just hangs up the asp pages. Any
fixes?

-Jon
"Gerhard Pretorius" <ge*****@compre hendit.net> wrote in message news:<uZ******* ******@TK2MSFTN GP12.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
5488
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
8
3372
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
351
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 named "System.Net.TlsStream". After that everything sems to be fine untill the next long idle period. The code is below.
4
2710
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 be populated in the textbox. I use the user control on a index.aspx page. In order to achieve this I have a selected intexchange event on the calendar control. I pass the textbox id using the querystring when the button is clicked and then...
1
2885
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: <asp:TextBox ID="Birthdate" runat="server" ValidationGroup="Birthdate" /> <asp:Button ID="Calendar" runat="server" Text="Calendar"
47
3133
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 ensure that subsequent requests will be queued until the current request is completed? If not, can IIS be configured to use seperate processes to satisfy requests for a nominated ASP page? Thanks in advance.
0
2184
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 select which department they will send the form to (we are trying to consolidate forms). This is what I have so far, but when I test the form, I keep getting this error message: Mailing Failed... Error is: FromAddress Property cannot be blank. You...
2
5325
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 was aborted: The request was canceled." and the inner exception is :{"Cannot close stream until all bytes are written."}
3
5048
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
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10749
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10419
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4618
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.