473,385 Members | 1,908 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,385 software developers and data experts.

Why does a class created in global.asa Application_Start get removed right away?

Hello,

I posted an this issue before but I'm clearer on what is going on.

I have a simple web site with a global.asa and a single .asp file.

In global.asa I handle both Application_OnStart and Application_OnEnd (see
below.)

The ShoreTelMakeCallTransfer object is a simple VB test object which
currently just logs class_initialize and class_terminate along with
OnStartPage and OnEndPage.

When I acess my ASP page, I see the folowing output from my logging:

--> Class_Initialize
<-- Class_Initialize

--> OnStartPage
<-- OnStartPage

--> OnEndPage
<-- OnEndPage

--> Class_Terminate
<-- Class_Termiante

What I don't understand is why Class_Terminate is called?

Based on the fact that in Application_OnStart I:

set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer

Shouldn't that cause the object to stay loaded????

Thanks, Grant Schenck

-------------------------------------------------------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Option Explicit

Sub Application_OnStart
On Error Resume Next
Dim ShoreTelMakeCallTransfer
Application("ShoreTelMakeCallTransfer") = NULL
set ShoreTelMakeCallTransfer =
Server.CreateObject("STMakeCallTransfer.STObject")
set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
End Sub

Sub Application_OnEnd
On Error Resume Next
Dim ShoreTelMakeCallTransfer
set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer")
set Application("ShoreTelMakeCallTransfer") = NULL
Application.Contents.Remove("ShoreTelMakeCallTrans fer")
End Sub

</SCRIPT>

Jul 22 '05 #1
5 3878
Of course as soon as I typed this I think I found the problem...

Specifically, because of my "On Error Resume Next" I was masking the
problem. Commenting those out give me:

-----------------------------------
Application object error 'ASP 0197 : 80004005'
Disallowed object use
/LM/W3SVC/1/Root/MyASP/global.asa, line 31
Cannot add object with apartment model behavior to the application intrinsic
object.
-----------------------------------

So, is this a drop dead issue? Is using STA type VB object not supported?

If so, can I use VB at all or must I use C++ and build an MTA?

Thanks, Grant Schenck
"Grant Schenck" <sc******@optonline.net> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
Hello,

I posted an this issue before but I'm clearer on what is going on.

I have a simple web site with a global.asa and a single .asp file.

In global.asa I handle both Application_OnStart and Application_OnEnd (see
below.)

The ShoreTelMakeCallTransfer object is a simple VB test object which
currently just logs class_initialize and class_terminate along with
OnStartPage and OnEndPage.

When I acess my ASP page, I see the folowing output from my logging:

--> Class_Initialize
<-- Class_Initialize

--> OnStartPage
<-- OnStartPage

--> OnEndPage
<-- OnEndPage

--> Class_Terminate
<-- Class_Termiante

What I don't understand is why Class_Terminate is called?

Based on the fact that in Application_OnStart I:

set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer

Shouldn't that cause the object to stay loaded????

Thanks, Grant Schenck

-------------------------------------------------------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Option Explicit

Sub Application_OnStart
On Error Resume Next
Dim ShoreTelMakeCallTransfer
Application("ShoreTelMakeCallTransfer") = NULL
set ShoreTelMakeCallTransfer =
Server.CreateObject("STMakeCallTransfer.STObject")
set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
End Sub

Sub Application_OnEnd
On Error Resume Next
Dim ShoreTelMakeCallTransfer
set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer")
set Application("ShoreTelMakeCallTransfer") = NULL
Application.Contents.Remove("ShoreTelMakeCallTrans fer")
End Sub

</SCRIPT>

Jul 22 '05 #2
start here:

http://www.aspfaq.com/show.asp?id=2053

What functions are you trying to make available globally through the object?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
Hello,

I posted an this issue before but I'm clearer on what is going on.

I have a simple web site with a global.asa and a single .asp file.

In global.asa I handle both Application_OnStart and Application_OnEnd (see
below.)

The ShoreTelMakeCallTransfer object is a simple VB test object which
currently just logs class_initialize and class_terminate along with
OnStartPage and OnEndPage.

When I acess my ASP page, I see the folowing output from my logging:

--> Class_Initialize
<-- Class_Initialize

--> OnStartPage
<-- OnStartPage

--> OnEndPage
<-- OnEndPage

--> Class_Terminate
<-- Class_Termiante

What I don't understand is why Class_Terminate is called?

Based on the fact that in Application_OnStart I:

set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer

Shouldn't that cause the object to stay loaded????

Thanks, Grant Schenck

-------------------------------------------------------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Option Explicit

Sub Application_OnStart
On Error Resume Next
Dim ShoreTelMakeCallTransfer
Application("ShoreTelMakeCallTransfer") = NULL
set ShoreTelMakeCallTransfer =
Server.CreateObject("STMakeCallTransfer.STObject")
set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
End Sub

Sub Application_OnEnd
On Error Resume Next
Dim ShoreTelMakeCallTransfer
set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer")
set Application("ShoreTelMakeCallTransfer") = NULL
Application.Contents.Remove("ShoreTelMakeCallTrans fer")
End Sub

</SCRIPT>

Jul 22 '05 #3
See my response to my own email.

It looks like you simply can NOT store an STA (VB) COM object in the
application.

It sounds like older versions of IIS did allow this. This seems like a
bogus limitation becasue at least in my case, the object methods are all
VERY fast and don't block the calling thread in any significant way.

So, does anyone have any reason to believe that this isn't true or if there
is anykind of workaround?

Thanks, Grant Schenck

"Mark Schupp" <no****@nospam.com> wrote in message
news:#f**************@TK2MSFTNGP15.phx.gbl...
start here:

http://www.aspfaq.com/show.asp?id=2053

What functions are you trying to make available globally through the object?
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
Hello,

I posted an this issue before but I'm clearer on what is going on.

I have a simple web site with a global.asa and a single .asp file.

In global.asa I handle both Application_OnStart and Application_OnEnd (see below.)

The ShoreTelMakeCallTransfer object is a simple VB test object which
currently just logs class_initialize and class_terminate along with
OnStartPage and OnEndPage.

When I acess my ASP page, I see the folowing output from my logging:

--> Class_Initialize
<-- Class_Initialize

--> OnStartPage
<-- OnStartPage

--> OnEndPage
<-- OnEndPage

--> Class_Terminate
<-- Class_Termiante

What I don't understand is why Class_Terminate is called?

Based on the fact that in Application_OnStart I:

set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer

Shouldn't that cause the object to stay loaded????

Thanks, Grant Schenck

-------------------------------------------------------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Option Explicit

Sub Application_OnStart
On Error Resume Next
Dim ShoreTelMakeCallTransfer
Application("ShoreTelMakeCallTransfer") = NULL
set ShoreTelMakeCallTransfer =
Server.CreateObject("STMakeCallTransfer.STObject")
set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
End Sub

Sub Application_OnEnd
On Error Resume Next
Dim ShoreTelMakeCallTransfer
set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer")
set Application("ShoreTelMakeCallTransfer") = NULL
Application.Contents.Remove("ShoreTelMakeCallTrans fer")
End Sub

</SCRIPT>


Jul 22 '05 #4
If I understand the threading issues the problem is that you would end up
tying every page containing the STA object to a single thread. IIRC you
could put some STA objects in Application scope in IIS4 but it was a bug not
a "feature".

You might be able to fool IIS into thinking your object was FreeThreaded by
changing the registry but you would be risking crashes if two threads tried
to access any global data at the same time.

Again, what are you trying to accomplish with your object? There may be
alternative methods available.

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
See my response to my own email.

It looks like you simply can NOT store an STA (VB) COM object in the
application.

It sounds like older versions of IIS did allow this. This seems like a
bogus limitation becasue at least in my case, the object methods are all
VERY fast and don't block the calling thread in any significant way.

So, does anyone have any reason to believe that this isn't true or if
there
is anykind of workaround?

Thanks, Grant Schenck

"Mark Schupp" <no****@nospam.com> wrote in message
news:#f**************@TK2MSFTNGP15.phx.gbl...
start here:

http://www.aspfaq.com/show.asp?id=2053

What functions are you trying to make available globally through the

object?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
> Hello,
>
> I posted an this issue before but I'm clearer on what is going on.
>
> I have a simple web site with a global.asa and a single .asp file.
>
> In global.asa I handle both Application_OnStart and Application_OnEnd (see > below.)
>
> The ShoreTelMakeCallTransfer object is a simple VB test object which
> currently just logs class_initialize and class_terminate along with
> OnStartPage and OnEndPage.
>
> When I acess my ASP page, I see the folowing output from my logging:
>
> --> Class_Initialize
> <-- Class_Initialize
>
> --> OnStartPage
> <-- OnStartPage
>
> --> OnEndPage
> <-- OnEndPage
>
> --> Class_Terminate
> <-- Class_Termiante
>
> What I don't understand is why Class_Terminate is called?
>
> Based on the fact that in Application_OnStart I:
>
> set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
>
> Shouldn't that cause the object to stay loaded????
>
> Thanks, Grant Schenck
>
> -------------------------------------------------------
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>
> Option Explicit
>
> Sub Application_OnStart
> On Error Resume Next
> Dim ShoreTelMakeCallTransfer
> Application("ShoreTelMakeCallTransfer") = NULL
> set ShoreTelMakeCallTransfer =
> Server.CreateObject("STMakeCallTransfer.STObject")
> set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer
> End Sub
>
> Sub Application_OnEnd
> On Error Resume Next
> Dim ShoreTelMakeCallTransfer
> set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer")
> set Application("ShoreTelMakeCallTransfer") = NULL
> Application.Contents.Remove("ShoreTelMakeCallTrans fer")
> End Sub
>
> </SCRIPT>
>
>
>



Jul 22 '05 #5
At this point I'll play by the rules and write an C++ based MTA. Internally
it will be using an STA but that should be OK... I believe...

Also, while were on the subject, the STA uses a windows timer. Do you know
if ASP->MTA->STA will allow a message pump be available to the STA?
--
Grant Schenck

"Mark Schupp" <no******@email.net> wrote in message
news:eK**************@TK2MSFTNGP15.phx.gbl...
If I understand the threading issues the problem is that you would end up
tying every page containing the STA object to a single thread. IIRC you
could put some STA objects in Application scope in IIS4 but it was a bug not a "feature".

You might be able to fool IIS into thinking your object was FreeThreaded by changing the registry but you would be risking crashes if two threads tried to access any global data at the same time.

Again, what are you trying to accomplish with your object? There may be
alternative methods available.

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
See my response to my own email.

It looks like you simply can NOT store an STA (VB) COM object in the
application.

It sounds like older versions of IIS did allow this. This seems like a
bogus limitation becasue at least in my case, the object methods are all
VERY fast and don't block the calling thread in any significant way.

So, does anyone have any reason to believe that this isn't true or if
there
is anykind of workaround?

Thanks, Grant Schenck

"Mark Schupp" <no****@nospam.com> wrote in message
news:#f**************@TK2MSFTNGP15.phx.gbl...
start here:

http://www.aspfaq.com/show.asp?id=2053

What functions are you trying to make available globally through the

object?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Grant Schenck" <sc******@optonline.net> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
> Hello,
>
> I posted an this issue before but I'm clearer on what is going on.
>
> I have a simple web site with a global.asa and a single .asp file.
>
> In global.asa I handle both Application_OnStart and Application_OnEnd

(see
> below.)
>
> The ShoreTelMakeCallTransfer object is a simple VB test object which
> currently just logs class_initialize and class_terminate along with
> OnStartPage and OnEndPage.
>
> When I acess my ASP page, I see the folowing output from my logging:
>
> --> Class_Initialize
> <-- Class_Initialize
>
> --> OnStartPage
> <-- OnStartPage
>
> --> OnEndPage
> <-- OnEndPage
>
> --> Class_Terminate
> <-- Class_Termiante
>
> What I don't understand is why Class_Terminate is called?
>
> Based on the fact that in Application_OnStart I:
>
> set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer >
> Shouldn't that cause the object to stay loaded????
>
> Thanks, Grant Schenck
>
> -------------------------------------------------------
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>
> Option Explicit
>
> Sub Application_OnStart
> On Error Resume Next
> Dim ShoreTelMakeCallTransfer
> Application("ShoreTelMakeCallTransfer") = NULL
> set ShoreTelMakeCallTransfer =
> Server.CreateObject("STMakeCallTransfer.STObject")
> set Application("ShoreTelMakeCallTransfer") = ShoreTelMakeCallTransfer > End Sub
>
> Sub Application_OnEnd
> On Error Resume Next
> Dim ShoreTelMakeCallTransfer
> set ShoreTelMakeCallTransfer = Application("ShoreTelMakeCallTransfer") > set Application("ShoreTelMakeCallTransfer") = NULL
> Application.Contents.Remove("ShoreTelMakeCallTrans fer")
> End Sub
>
> </SCRIPT>
>
>
>



Jul 22 '05 #6

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

Similar topics

12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
4
by: Israel Ordonez Jr | last post by:
Hi everybody, I am having a problem with an ASP.NET application i am working on. I new to ASP.NET so I'm not sure if I'm doing this right. I am working on a website that has an oil price listed...
19
by: Shiv Kumar | last post by:
I see that the Application_OnStart event is fired only once for a certain application. I'm interested in creating a "global" object (an object that will be available to all requests for the...
5
by: Victor Jones | last post by:
I had a question about accessing HttpContext.User in global.asax. I was trying to access HttpContext.User in Application_BeginRequest() which had a null value as opposed to containing a valid...
1
by: Fernando Arámburu | last post by:
Hy everybody, I´m working on an ASP.NET framework and and I need to extend System.Web.HttpApplication. I mean, I need to put some intermediate class between System.Web.HttpApplication and Global...
4
by: NoNickname | last post by:
Hi, I need to get a string from a COM component at application start. (It's a Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called this COM component in Global.asax.cs...
3
by: Trygve Lorentzen | last post by:
Hi, I don't know if this is a stupid question, but I observe that my webservice is created for each call to a webmethod. More precisely an instance of the webservice class is created for each...
3
by: Mike Owen | last post by:
Hi, I have set up a new web site application in VS 2005, and have created a couple of pages which seem to run ok. I then manually added a file called Global.asax.vb, within a folder that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.