calling Session.Contents.Remove in VB COM = crash!! 
Author Message
 calling Session.Contents.Remove in VB COM = crash!!

Hello,

I hope someone can help shed some light on an issue I am
dealing with.

I have a VB COM obj that is importing the ScriptingContext
from the calling ASP page. Within my VB COM object, I have
code which loops through the Session.Contents collection
and deletes some session items based on some criteria.

The issue is that when the VB COM obj gets to the
oSession.Contents.Remove(item) code, it hangs and
ultimately crashes.

Anyone know about this??

thanks in advance.

roy.



Sun, 02 Oct 2005 05:32:10 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
Hi Roy,

According to the test on my side, this problem doesn't occur. I wonder if
the parameter for Contents.Remove is correct. It should be the key for the
Contents dictionary. This is documented in the following MSDN article:

http://msdn.microsoft.com/library/en-us/iisref/htm/ref_biobj_cppivd.asp

The key of the item can be retrieved using the Contents.Key property.

For example, I have following code in the ASP:


<% for x = 1 to 10
session(x)=x*20
next
response.write session("4")
%>

Then, I can use following VB code to remove the session:

        Dim objContext As ObjectContext
        Dim objResponse As Response
        Dim objSession As Session

        Set objContext = GetObjectContext()

        Set objApplication = objContext("Application") 'Obtain ASP
Application object.
        Set objSession = objContext("Session") 'Obtain ASP Session object.
        Set objResponse = objContext("Response") ' Obtain ASP Response
object.

        objResponse.Write "COM" & vbCrLf
        For Each itm In objSession.Contents
            objResponse.Write itm & vbCrLf
        Next

        objSession.Contents.Remove ("3")

      Set objContext = Nothing
      Set objResponse = Nothing
      Set objSession = Nothing

In addition, you may check the article below for more information about
retrieving ASP intrinsic object:

323259 HOW TO: Access ASP.NET Intrinsic Objects in a Visual Basic 6.0
Component
http://support.microsoft.com/?id=323259

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message


| Subject: calling Session.Contents.Remove in VB COM  = crash!!
| Date: Tue, 15 Apr 2003 14:32:10 -0700
| Lines: 20

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
| Newsgroups: microsoft.public.vb.com
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35584
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.vb.com
|
| Hello,
|
| I hope someone can help shed some light on an issue I am
| dealing with.
|
| I have a VB COM obj that is importing the ScriptingContext
| from the calling ASP page. Within my VB COM object, I have
| code which loops through the Session.Contents collection
| and deletes some session items based on some criteria.
|
| The issue is that when the VB COM obj gets to the
| oSession.Contents.Remove(item) code, it hangs and
| ultimately crashes.
|
| Anyone know about this??
|
| thanks in advance.
|
| roy.
|
|



Sun, 02 Oct 2005 16:26:31 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
Hmmm, I have pretty much the same thing you have, except
that I am importing the context a little differently. I
wonder if thats my problem. I have the following...

Public Sub OnStartPage(oScriptingContext As
ScriptingContext)
    Set oSession = oScriptingContext.Session
    Set oRequest = oScriptingContext.Request
    Set oResponse = oScriptingContext.Response
End Sub

One other wierd thing; I have an On Error Goto errHandler
in my code, but when the "contents.remove" line of code
runs, the error gets caught by IIS/ASP, not in VB.

Quote:
>-----Original Message-----
>Hi Roy,

>According to the test on my side, this problem doesn't
occur. I wonder if
>the parameter for Contents.Remove is correct. It should
be the key for the
>Contents dictionary. This is documented in the following
MSDN article:

>http://msdn.microsoft.com/library/en-

us/iisref/htm/ref_biobj_cppivd.asp
Quote:

>The key of the item can be retrieved using the

Contents.Key property.
Quote:

>For example, I have following code in the ASP:


><% for x = 1 to 10
>session(x)=x*20
>next
>response.write session("4")
>%>

>Then, I can use following VB code to remove the session:

>        Dim objContext As ObjectContext
>        Dim objResponse As Response
>        Dim objSession As Session

>        Set objContext = GetObjectContext()

>        Set objApplication = objContext

("Application") 'Obtain ASP

- Show quoted text -

Quote:
>Application object.
>        Set objSession = objContext("Session") 'Obtain
ASP Session object.
>        Set objResponse = objContext("Response") ' Obtain
ASP Response
>object.

>        objResponse.Write "COM" & vbCrLf
>        For Each itm In objSession.Contents
>            objResponse.Write itm & vbCrLf
>        Next

>        objSession.Contents.Remove ("3")

>      Set objContext = Nothing
>      Set objResponse = Nothing
>      Set objSession = Nothing

>In addition, you may check the article below for more
information about
>retrieving ASP intrinsic object:

>323259 HOW TO: Access ASP.NET Intrinsic Objects in a
Visual Basic 6.0
>Component
>http://support.microsoft.com/?id=323259

>Best Regards,
>Leo Chen

>This posting is provided "AS IS" with no warranties, and
confers no rights.

>--------------------
>| Content-Class: urn:content-classes:message


>| Subject: calling Session.Contents.Remove in VB COM  =
crash!!
>| Date: Tue, 15 Apr 2003 14:32:10 -0700
>| Lines: 20

>| MIME-Version: 1.0
>| Content-Type: text/plain;
>|   charset="iso-8859-1"
>| Content-Transfer-Encoding: 7bit
>| X-Newsreader: Microsoft CDO for Windows 2000
>| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
>| Newsgroups: microsoft.public.vb.com
>| Path: cpmsftngxa06.phx.gbl
>| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35584
>| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
>| X-Tomcat-NG: microsoft.public.vb.com
>|
>| Hello,
>|
>| I hope someone can help shed some light on an issue I
am
>| dealing with.
>|
>| I have a VB COM obj that is importing the
ScriptingContext
>| from the calling ASP page. Within my VB COM object, I
have
>| code which loops through the Session.Contents
collection
>| and deletes some session items based on some criteria.
>|
>| The issue is that when the VB COM obj gets to the
>| oSession.Contents.Remove(item) code, it hangs and
>| ultimately crashes.
>|
>| Anyone know about this??
>|
>| thanks in advance.
>|
>| roy.
>|
>|

>.



Sun, 02 Oct 2005 22:17:07 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
ok, after a little research, it seems that I'm not
supposed to be using the ScriptingContext approach, but
rather the ObjectContect approach. With this in mind, I
have a couple questions...

Does that mean that I have to run my VB COM object under
MTS?

There seems to be a lot of posts on Google regarding
issues with running the object in the VB de{*filter*} and
getting nothing back from the GetObjectContext() call. Is
this still an issue?

Quote:
>-----Original Message-----
>Hi Roy,

>According to the test on my side, this problem doesn't
occur. I wonder if
>the parameter for Contents.Remove is correct. It should
be the key for the
>Contents dictionary. This is documented in the following
MSDN article:

> http://www.*-*-*.com/

us/iisref/htm/ref_biobj_cppivd.asp
Quote:

>The key of the item can be retrieved using the

Contents.Key property.
Quote:

>For example, I have following code in the ASP:


><% for x = 1 to 10
>session(x)=x*20
>next
>response.write session("4")
>%>

>Then, I can use following VB code to remove the session:

>        Dim objContext As ObjectContext
>        Dim objResponse As Response
>        Dim objSession As Session

>        Set objContext = GetObjectContext()

>        Set objApplication = objContext

("Application") 'Obtain ASP

- Show quoted text -

Quote:
>Application object.
>        Set objSession = objContext("Session") 'Obtain
ASP Session object.
>        Set objResponse = objContext("Response") ' Obtain
ASP Response
>object.

>        objResponse.Write "COM" & vbCrLf
>        For Each itm In objSession.Contents
>            objResponse.Write itm & vbCrLf
>        Next

>        objSession.Contents.Remove ("3")

>      Set objContext = Nothing
>      Set objResponse = Nothing
>      Set objSession = Nothing

>In addition, you may check the article below for more
information about
>retrieving ASP intrinsic object:

>323259 HOW TO: Access ASP.NET Intrinsic Objects in a
Visual Basic 6.0
>Component
> http://www.*-*-*.com/

>Best Regards,
>Leo Chen

>This posting is provided "AS IS" with no warranties, and
confers no rights.

>--------------------
>| Content-Class: urn:content-classes:message


>| Subject: calling Session.Contents.Remove in VB COM  =
crash!!
>| Date: Tue, 15 Apr 2003 14:32:10 -0700
>| Lines: 20

>| MIME-Version: 1.0
>| Content-Type: text/plain;
>|   charset="iso-8859-1"
>| Content-Transfer-Encoding: 7bit
>| X-Newsreader: Microsoft CDO for Windows 2000
>| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
>| Newsgroups: microsoft.public.vb.com
>| Path: cpmsftngxa06.phx.gbl
>| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35584
>| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
>| X-Tomcat-NG: microsoft.public.vb.com
>|
>| Hello,
>|
>| I hope someone can help shed some light on an issue I
am
>| dealing with.
>|
>| I have a VB COM obj that is importing the
ScriptingContext
>| from the calling ASP page. Within my VB COM object, I
have
>| code which loops through the Session.Contents
collection
>| and deletes some session items based on some criteria.
>|
>| The issue is that when the VB COM obj gets to the
>| oSession.Contents.Remove(item) code, it hangs and
>| ultimately crashes.
>|
>| Anyone know about this??
>|
>| thanks in advance.
>|
>| roy.
>|
>|

>.



Mon, 03 Oct 2005 05:42:46 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
Hi Roy,

Thanks for the replying.

To debug VB component in COM+, we can refer to the following article:

299633 HOW TO: Debug Visual Basic COM Components That Are Used Within Active
http://www.*-*-*.com/

259725 PRB: Error Occurs When You Debug a COM+ Component Under the Visual
Basic
http://www.*-*-*.com/

Additionally, in Windows 2000 and later, we are using COM+, so the old MTS
issues documented in the following article may not apply.

188919 HOWTO: Avoid "Error 91" when Debugging MTS Components with Visual
Basic
http://www.*-*-*.com/

We don't need to configure it in COM+, as it will be involved automatically
by COM+.

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message




| Subject: RE: calling Session.Contents.Remove in VB COM  = crash!!
| Date: Wed, 16 Apr 2003 14:42:46 -0700
| Lines: 138

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcMEYR4xHQlEy95kRqSmpuPksRSfeg==
| Newsgroups: microsoft.public.vb.com
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35608
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.vb.com
|
| ok, after a little research, it seems that I'm not
| supposed to be using the ScriptingContext approach, but
| rather the ObjectContect approach. With this in mind, I
| have a couple questions...
|
| Does that mean that I have to run my VB COM object under
| MTS?
|
| There seems to be a lot of posts on Google regarding
| issues with running the object in the VB de{*filter*} and
| getting nothing back from the GetObjectContext() call. Is
| this still an issue?
|
|

Quote:
| >-----Original Message-----
| >Hi Roy,
| >
| >According to the test on my side, this problem doesn't
| occur. I wonder if
| >the parameter for Contents.Remove is correct. It should
| be the key for the
| >Contents dictionary. This is documented in the following
| MSDN article:
| >
| > http://www.*-*-*.com/
| us/iisref/htm/ref_biobj_cppivd.asp
| >
| >The key of the item can be retrieved using the
| Contents.Key property.
| >
| >For example, I have following code in the ASP:
| >

| ><% for x = 1 to 10
| >session(x)=x*20
| >next
| >response.write session("4")
| >%>
| >
| >Then, I can use following VB code to remove the session:
| >
| >        Dim objContext As ObjectContext
| >        Dim objResponse As Response
| >        Dim objSession As Session
| >
| >
| >        Set objContext = GetObjectContext()
| >
| >        Set objApplication = objContext
| ("Application") 'Obtain ASP
| >Application object.
| >        Set objSession = objContext("Session") 'Obtain
| ASP Session object.
| >        Set objResponse = objContext("Response") ' Obtain
| ASP Response
| >object.
| >
| >
| >        objResponse.Write "COM" & vbCrLf
| >        For Each itm In objSession.Contents
| >            objResponse.Write itm & vbCrLf
| >        Next
| >
| >
| >        objSession.Contents.Remove ("3")
| >
| >
| >      Set objContext = Nothing
| >      Set objResponse = Nothing
| >      Set objSession = Nothing
| >      
| >
| >In addition, you may check the article below for more
| information about
| >retrieving ASP intrinsic object:
| >
| >323259 HOW TO: Access ASP.NET Intrinsic Objects in a
| Visual Basic 6.0
| >Component
| > http://www.*-*-*.com/
| >
| >Best Regards,
| >Leo Chen
| >
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >
| >
| >--------------------
| >| Content-Class: urn:content-classes:message


| >| Subject: calling Session.Contents.Remove in VB COM  =
| crash!!
| >| Date: Tue, 15 Apr 2003 14:32:10 -0700
| >| Lines: 20

| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >|         charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
| >| Newsgroups: microsoft.public.vb.com
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35584
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.vb.com
| >|
| >| Hello,
| >|
| >| I hope someone can help shed some light on an issue I
| am
| >| dealing with.
| >|
| >| I have a VB COM obj that is importing the
| ScriptingContext
| >| from the calling ASP page. Within my VB COM object, I
| have
| >| code which loops through the Session.Contents
| collection
| >| and deletes some session items based on some criteria.
| >|
| >| The issue is that when the VB COM obj gets to the
| >| oSession.Contents.Remove(item) code, it hangs and
| >| ultimately crashes.
| >|
| >| Anyone know about this??
| >|
| >| thanks in advance.
| >|
| >| roy.
| >|
| >|
| >
| >.
| >
|



Mon, 03 Oct 2005 10:08:40 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
Hi Leo,

Thanks for all oyur help. So, here's where I am:

1. started out trying to figure out why the VB IDE crashed
whenever Session.Contents.Remove(key) executed in debug
mode, but not in compiled/normal run mode.

1. I replaced my ScriptingContext import (in the
onPageStart event), with a call to GetObjectContext() in a
different function called Init() that gets called by the
ASP right after the object is instantiated. I was thinking
that this might help the crash situation.

2. I found right away that GetObjectContext() was
returning "Nothing".

3. I put my DLL under COM+ using the MMC located
at /Start/Administrative Tools/Component Services at then
started seeing an actual object reference returned by
GetObjectContext(), but the calls to Remove() still
crashed the VB IDE when run in debug mode. The calls still
work in compiled mode.

4. Since the switch from ScriptDContext to ObjectContext
didn't fix the VB IDE crash problem I'm seeing, and to
minimize installation overhead for this object, I reverted
back to the ScriptingContext import way that I started
with.

5. Bottom line, the object performs as expected unless
running in the VB IDE under debug mode, at which point the
VB IDE crashes when executing any of the
Session.Contents.Remove methods

When you did your sample, did you run it in the VB
de{*filter*} to see if it crashes on you?

thanks again for all your help

Quote:
>-----Original Message-----
>Hi Roy,

>Thanks for the replying.

>To debug VB component in COM+, we can refer to the
following article:

>299633 HOW TO: Debug Visual Basic COM Components That Are
Used Within Active
> http://www.*-*-*.com/

>259725 PRB: Error Occurs When You Debug a COM+ Component
Under the Visual
>Basic
> http://www.*-*-*.com/

>Additionally, in Windows 2000 and later, we are using

COM+, so the old MTS
Quote:
>issues documented in the following article may not apply.

>188919 HOWTO: Avoid "Error 91" when Debugging MTS

Components with Visual
Quote:
>Basic
> http://www.*-*-*.com/

>We don't need to configure it in COM+, as it will be

involved automatically

- Show quoted text -

Quote:
>by COM+.

>Best Regards,
>Leo Chen

>This posting is provided "AS IS" with no warranties, and
confers no rights.

>--------------------
>| Content-Class: urn:content-classes:message




>| Subject: RE: calling Session.Contents.Remove in VB COM  
= crash!!
>| Date: Wed, 16 Apr 2003 14:42:46 -0700
>| Lines: 138

>| MIME-Version: 1.0
>| Content-Type: text/plain;
>|   charset="iso-8859-1"
>| Content-Transfer-Encoding: 7bit
>| X-Newsreader: Microsoft CDO for Windows 2000
>| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>| Thread-Index: AcMEYR4xHQlEy95kRqSmpuPksRSfeg==
>| Newsgroups: microsoft.public.vb.com
>| Path: cpmsftngxa06.phx.gbl
>| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35608
>| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
>| X-Tomcat-NG: microsoft.public.vb.com
>|
>| ok, after a little research, it seems that I'm not
>| supposed to be using the ScriptingContext approach, but
>| rather the ObjectContect approach. With this in mind, I
>| have a couple questions...
>|
>| Does that mean that I have to run my VB COM object
under
>| MTS?
>|
>| There seems to be a lot of posts on Google regarding
>| issues with running the object in the VB de{*filter*} and
>| getting nothing back from the GetObjectContext() call.
Is
>| this still an issue?
>|
>|
>| >-----Original Message-----
>| >Hi Roy,
>| >
>| >According to the test on my side, this problem doesn't
>| occur. I wonder if
>| >the parameter for Contents.Remove is correct. It
should
>| be the key for the
>| >Contents dictionary. This is documented in the
following
>| MSDN article:
>| >
>| > http://www.*-*-*.com/
>| us/iisref/htm/ref_biobj_cppivd.asp
>| >
>| >The key of the item can be retrieved using the
>| Contents.Key property.
>| >
>| >For example, I have following code in the ASP:
>| >

>| ><% for x = 1 to 10
>| >session(x)=x*20
>| >next
>| >response.write session("4")
>| >%>
>| >
>| >Then, I can use following VB code to remove the
session:
>| >
>| >        Dim objContext As ObjectContext
>| >        Dim objResponse As Response
>| >        Dim objSession As Session
>| >
>| >
>| >        Set objContext = GetObjectContext()
>| >
>| >        Set objApplication = objContext
>| ("Application") 'Obtain ASP
>| >Application object.
>| >        Set objSession = objContext("Session") 'Obtain
>| ASP Session object.
>| >        Set objResponse = objContext("Response") '
Obtain
>| ASP Response
>| >object.
>| >
>| >
>| >        objResponse.Write "COM" & vbCrLf
>| >        For Each itm In objSession.Contents
>| >            objResponse.Write itm & vbCrLf
>| >        Next
>| >
>| >
>| >        objSession.Contents.Remove ("3")
>| >
>| >
>| >      Set objContext = Nothing
>| >      Set objResponse = Nothing
>| >      Set objSession = Nothing
>| >      
>| >
>| >In addition, you may check the article below for more
>| information about
>| >retrieving ASP intrinsic object:
>| >
>| >323259 HOW TO: Access ASP.NET Intrinsic Objects in a
>| Visual Basic 6.0
>| >Component
>| > http://www.*-*-*.com/
>| >
>| >Best Regards,
>| >Leo Chen
>| >
>| >This posting is provided "AS IS" with no warranties,
and
>| confers no rights.
>| >
>| >
>| >--------------------
>| >| Content-Class: urn:content-classes:message


>| >| Subject: calling Session.Contents.Remove in VB COM  
=
>| crash!!
>| >| Date: Tue, 15 Apr 2003 14:32:10 -0700
>| >| Lines: 20

>| >| MIME-Version: 1.0
>| >| Content-Type: text/plain;
>| >|     charset="iso-8859-1"
>| >| Content-Transfer-Encoding: 7bit
>| >| X-Newsreader: Microsoft CDO for Windows 2000
>| >| X-MimeOLE: Produced By Microsoft MimeOLE
V5.50.4910.0300
>| >| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
>| >| Newsgroups: microsoft.public.vb.com
>| >| Path: cpmsftngxa06.phx.gbl
>| >| Xref: cpmsftngxa06.phx.gbl

microsoft.public.vb.com:35584

- Show quoted text -

Quote:
>| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
>| >| X-Tomcat-NG: microsoft.public.vb.com
>| >|
>| >| Hello,
>| >|
>| >| I hope someone can help shed some light on an issue
I
>| am
>| >| dealing with.
>| >|
>| >| I have a VB COM obj that is importing the
>| ScriptingContext
>| >| from the calling ASP page. Within my VB COM object,
I
>| have
>| >| code which loops through the Session.Contents
>| collection
>| >| and deletes some session items based on some
criteria.
>| >|
>| >| The issue is that when the VB COM obj gets to the
>| >| oSession.Contents.Remove(item) code, it hangs and
>| >| ultimately crashes.
>| >|
>| >| Anyone know about this??
>| >|
>| >| thanks in advance.
>| >|
>| >| roy.
>| >|
>| >|
>| >
>| >.
>| >
>|

>.



Mon, 03 Oct 2005 12:36:08 GMT  
 calling Session.Contents.Remove in VB COM = crash!!
Hi Roy,

Here are the steps to debug the component on my side. It works
successfully, and the context is returned:

1. In the Project properties, select "Unattended Execution" and "Retain in
Memory".
2. In the properties of the class, choose "MTSTransactionMode" to a value
greater than 0. Here I chose "1-NoTransactions".
3. Add the VB 6 application ID in the registry.
4. I didn't compile the DLL, just press F5 in VB and wait for the
breakpoint to be hit.

To isolate this problem, you may create a simple VB component and ASP code
to test this behavior. For your reference, I'm including my testing code
below:

VB:

        Dim objContext As ObjectContext
        Dim objResponse As Response
        Dim objSession As Session

        Set objContext = GetObjectContext()

        Set objApplication = objContext("Application") 'Obtain ASP
Application object.
        Set objSession = objContext("Session") 'Obtain ASP Session object.
        Set objResponse = objContext("Response") ' Obtain ASP Response
object.

        For Each itm In objSession.Contents
            objResponse.Write itm
        Next

        objSession.Contents.Remove ("3")

      Set objContext = Nothing
      Set objResponse = Nothing
      Set objSession = Nothing

ASP:


<% for x = 1 to 10
session(x)=x*20
next
response.write session("4")

set o = Server.CreateObject("VBASP.Foo")
o.Bar()
set o=nothing
%>

If this problem persists with this simple component, this problem seems to
be the VB IDE itself has some problems. You may try reapplying the VS SP5
update. For your reference, I'm including the URL below:

http://www.*-*-*.com/

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message






| Subject: RE: calling Session.Contents.Remove in VB COM  = crash!!
| Date: Wed, 16 Apr 2003 21:36:08 -0700
| Lines: 256

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcMEmt1LuBtnvmpoTlC/gETZ0WNsPA==
| Newsgroups: microsoft.public.vb.com
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35617
| NNTP-Posting-Host: TK2MSFTNGXA01 10.40.1.47
| X-Tomcat-NG: microsoft.public.vb.com
|
| Hi Leo,
|
| Thanks for all oyur help. So, here's where I am:
|
| 1. started out trying to figure out why the VB IDE crashed
| whenever Session.Contents.Remove(key) executed in debug
| mode, but not in compiled/normal run mode.
|
| 1. I replaced my ScriptingContext import (in the
| onPageStart event), with a call to GetObjectContext() in a
| different function called Init() that gets called by the
| ASP right after the object is instantiated. I was thinking
| that this might help the crash situation.
|
| 2. I found right away that GetObjectContext() was
| returning "Nothing".
|
| 3. I put my DLL under COM+ using the MMC located
| at /Start/Administrative Tools/Component Services at then
| started seeing an actual object reference returned by
| GetObjectContext(), but the calls to Remove() still
| crashed the VB IDE when run in debug mode. The calls still
| work in compiled mode.
|
| 4. Since the switch from ScriptDContext to ObjectContext
| didn't fix the VB IDE crash problem I'm seeing, and to
| minimize installation overhead for this object, I reverted
| back to the ScriptingContext import way that I started
| with.
|
| 5. Bottom line, the object performs as expected unless
| running in the VB IDE under debug mode, at which point the
| VB IDE crashes when executing any of the
| Session.Contents.Remove methods
|
| When you did your sample, did you run it in the VB
| de{*filter*} to see if it crashes on you?
|
| thanks again for all your help
|

Quote:
| >-----Original Message-----
| >Hi Roy,
| >
| >Thanks for the replying.
| >
| >To debug VB component in COM+, we can refer to the
| following article:
| >
| >299633 HOW TO: Debug Visual Basic COM Components That Are
| Used Within Active
| > http://www.*-*-*.com/
| >
| >259725 PRB: Error Occurs When You Debug a COM+ Component
| Under the Visual
| >Basic
| > http://www.*-*-*.com/
| >
| >Additionally, in Windows 2000 and later, we are using
| COM+, so the old MTS
| >issues documented in the following article may not apply.
| >
| >188919 HOWTO: Avoid "Error 91" when Debugging MTS
| Components with Visual
| >Basic
| > http://www.*-*-*.com/
| >
| >We don't need to configure it in COM+, as it will be
| involved automatically
| >by COM+.
| >
| >Best Regards,
| >Leo Chen
| >
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >
| >
| >--------------------
| >| Content-Class: urn:content-classes:message




| >| Subject: RE: calling Session.Contents.Remove in VB COM  
| = crash!!
| >| Date: Wed, 16 Apr 2003 14:42:46 -0700
| >| Lines: 138

| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >|         charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcMEYR4xHQlEy95kRqSmpuPksRSfeg==
| >| Newsgroups: microsoft.public.vb.com
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl microsoft.public.vb.com:35608
| >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| >| X-Tomcat-NG: microsoft.public.vb.com
| >|
| >| ok, after a little research, it seems that I'm not
| >| supposed to be using the ScriptingContext approach, but
| >| rather the ObjectContect approach. With this in mind, I
| >| have a couple questions...
| >|
| >| Does that mean that I have to run my VB COM object
| under
| >| MTS?
| >|
| >| There seems to be a lot of posts on Google regarding
| >| issues with running the object in the VB de{*filter*} and
| >| getting nothing back from the GetObjectContext() call.
| Is
| >| this still an issue?
| >|
| >|
| >| >-----Original Message-----
| >| >Hi Roy,
| >| >
| >| >According to the test on my side, this problem doesn't
| >| occur. I wonder if
| >| >the parameter for Contents.Remove is correct. It
| should
| >| be the key for the
| >| >Contents dictionary. This is documented in the
| following
| >| MSDN article:
| >| >
| >| > http://www.*-*-*.com/
| >| us/iisref/htm/ref_biobj_cppivd.asp
| >| >
| >| >The key of the item can be retrieved using the
| >| Contents.Key property.
| >| >
| >| >For example, I have following code in the ASP:
| >| >

| >| ><% for x = 1 to 10
| >| >session(x)=x*20
| >| >next
| >| >response.write session("4")
| >| >%>
| >| >
| >| >Then, I can use following VB code to remove the
| session:
| >| >
| >| >        Dim objContext As ObjectContext
| >| >        Dim objResponse As Response
| >| >        Dim objSession As Session
| >| >
| >| >
| >| >        Set objContext = GetObjectContext()
| >| >
| >| >        Set objApplication = objContext
| >| ("Application") 'Obtain ASP
| >| >Application object.
| >| >        Set objSession = objContext("Session") 'Obtain
| >| ASP Session object.
| >| >        Set objResponse = objContext("Response") '
| Obtain
| >| ASP Response
| >| >object.
| >| >
| >| >
| >| >        objResponse.Write "COM" & vbCrLf
| >| >        For Each itm In objSession.Contents
| >| >            objResponse.Write itm & vbCrLf
| >| >        Next
| >| >
| >| >
| >| >        objSession.Contents.Remove ("3")
| >| >
| >| >
| >| >      Set objContext = Nothing
| >| >      Set objResponse = Nothing
| >| >      Set objSession = Nothing
| >| >      
| >| >
| >| >In addition, you may check the article below for more
| >| information about
| >| >retrieving ASP intrinsic object:
| >| >
| >| >323259 HOW TO: Access ASP.NET Intrinsic Objects in a
| >| Visual Basic 6.0
| >| >Component
| >| > http://www.*-*-*.com/
| >| >
| >| >Best Regards,
| >| >Leo Chen
| >| >
| >| >This posting is provided "AS IS" with no warranties,
| and
| >| confers no rights.
| >| >
| >| >
| >| >--------------------
| >| >| Content-Class: urn:content-classes:message


| >| >| Subject: calling Session.Contents.Remove in VB COM  
| =
| >| crash!!
| >| >| Date: Tue, 15 Apr 2003 14:32:10 -0700
| >| >| Lines: 20

| >| >| MIME-Version: 1.0
| >| >| Content-Type: text/plain;
| >| >|   charset="iso-8859-1"
| >| >| Content-Transfer-Encoding: 7bit
| >| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| >| Thread-Index: AcMDlnjG0GtHfqj2QiiOc6nwup1ceA==
| >| >| Newsgroups: microsoft.public.vb.com
| >| >| Path: cpmsftngxa06.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.vb.com:35584
| >| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| >| X-Tomcat-NG: microsoft.public.vb.com
| >| >|
| >| >| Hello,
| >| >|
| >| >| I hope someone can help shed some light on an issue
| I
| >| am
| >| >| dealing with.
| >| >|
| >| >| I have a VB COM obj that is importing the
| >|

...

read more »



Mon, 03 Oct 2005 20:30:21 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Access Session from a VB COM called from ASP

2. Problem with Session.Contents.Remove

3. Call VB DLL or COM object from within VB COM object or EXE

4. Calling COM crashes VB6

5. Removing session cookie with VB

6. Calling COM EXE from VB.NET Service leaves COM EXE in Memory

7. Call to Java COM inside VB COM

8. com object will not read registry when com object called from asp (vb works fine)

9. VB crashes after I remove strange hidden controls

10. VB crashes after I remove strange hidden controls

11. VB.NET crashing from my com server events

12. VB using COM crashed in IDE, exe is fine

 

 
Powered by phpBB® Forum Software