Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Why does a class created in global.asa Application_Start get removed right away?

Reply
Thread Tools

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

 
 
Grant Schenck
Guest
Posts: n/a
 
      04-14-2005
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>



 
Reply With Quote
 
 
 
 
Grant Schenck
Guest
Posts: n/a
 
      04-14-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
>
>
>



 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      04-14-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
>
>
>



 
Reply With Quote
 
Grant Schenck
Guest
Posts: n/a
 
      04-14-2005
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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>
> >
> >
> >

>
>



 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      04-14-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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>
>> >
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Grant Schenck
Guest
Posts: n/a
 
      04-14-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > 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>
> >> >
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Application_Start(Object sender, EventArgs e) - When does it realy runs? mswc.net ASP .Net 2 04-26-2005 08:04 PM
tempfiles created by tmpfile removed at exit - can I change this easily? Graham Nicholls Ruby 6 10-12-2004 03:40 PM
Why does Application_Start fire twice? Rashad Rivera ASP .Net 5 05-01-2004 02:37 AM



Advertisments