473,785 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple application objects?

SL
All,

As I understand it, a single application (i.e. IIS virtual directory)
in ASP.NET may in fact have more than one corresponding
HttpApplication State object (more or less one per server thread, I
think). During each request, only one of these objects is exposed to
the page as Page.Applicatio n. This seems to be supported by the fact
that when I use the debugger, I can see the Application_Sta rt event
firing more than one time even though IIS has not been shut down in
between.

My question is this - within my application, I want to instantiate a
specific COM object, and then I want to store this one instance some
place where it will a) remain until IIS shuts down and b) is
accessible by all pages, during all requests, regardless of exactly
which application object is being used by each request. Due to the
way that this particular COM component was written, I can only have
one instance of the COM object in question at any time. If I try to
have more than one instance exist concurently, they both enter an
invalid state and can no longer be used.

What I initially tried was instantiating my object on
Application_Sta rt, and then saving myObject to the application object.
But later on, Application_Sta rt invariably fires again and I end up
re-creating the object, because I can not see it on the current
application object. Meanwhile the original application object still
has its own instance of my COM object, so two instances now exist but
they both enter an invalid state.

Any help would be greatly appreciated.
Nov 18 '05 #1
3 1922
I'm afraid you're mistaken in your initial premise. There is only one
Application. Check Task Manager if you don't believe me. I have no idea what
you're doing to see the Application_Sta rt event firing more than once, but
it only fires one time when the application starts. When you debug, it will
restart and fire every time you re-run the debugger.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"SL" <sk***********@ yahoo.com> wrote in message
news:53******** *************** ***@posting.goo gle.com...
All,

As I understand it, a single application (i.e. IIS virtual directory)
in ASP.NET may in fact have more than one corresponding
HttpApplication State object (more or less one per server thread, I
think). During each request, only one of these objects is exposed to
the page as Page.Applicatio n. This seems to be supported by the fact
that when I use the debugger, I can see the Application_Sta rt event
firing more than one time even though IIS has not been shut down in
between.

My question is this - within my application, I want to instantiate a
specific COM object, and then I want to store this one instance some
place where it will a) remain until IIS shuts down and b) is
accessible by all pages, during all requests, regardless of exactly
which application object is being used by each request. Due to the
way that this particular COM component was written, I can only have
one instance of the COM object in question at any time. If I try to
have more than one instance exist concurently, they both enter an
invalid state and can no longer be used.

What I initially tried was instantiating my object on
Application_Sta rt, and then saving myObject to the application object.
But later on, Application_Sta rt invariably fires again and I end up
re-creating the object, because I can not see it on the current
application object. Meanwhile the original application object still
has its own instance of my COM object, so two instances now exist but
they both enter an invalid state.

Any help would be greatly appreciated.

Nov 18 '05 #2
while there are multiple Application instantences, there is only one cache,
and Application start only fires once per AppDomain.

here is the rub. asp.net will load a new appdomain for your site if it
believes there are any code changes, or that the site needs recycling, or
its hit the timeout. the old appdomain will stay in memory until its
serviced all of its current transactions, and run its shutdown.

while appdomains have their own memory and .net objects are distinct, com
objects use the asp.net memory. you will have to write some unmanaged code
to manage the com objects. the unmanged code will be called by application
start, and return the handle to the com object. it internally will need to
create one instance of the com object and track that its been created.

you also may be able to host the com object in com+ and make it a singleton.

-- bruce (sqlwork.com)
"SL" <sk***********@ yahoo.com> wrote in message
news:53******** *************** ***@posting.goo gle.com...
All,

As I understand it, a single application (i.e. IIS virtual directory)
in ASP.NET may in fact have more than one corresponding
HttpApplication State object (more or less one per server thread, I
think). During each request, only one of these objects is exposed to
the page as Page.Applicatio n. This seems to be supported by the fact
that when I use the debugger, I can see the Application_Sta rt event
firing more than one time even though IIS has not been shut down in
between.

My question is this - within my application, I want to instantiate a
specific COM object, and then I want to store this one instance some
place where it will a) remain until IIS shuts down and b) is
accessible by all pages, during all requests, regardless of exactly
which application object is being used by each request. Due to the
way that this particular COM component was written, I can only have
one instance of the COM object in question at any time. If I try to
have more than one instance exist concurently, they both enter an
invalid state and can no longer be used.

What I initially tried was instantiating my object on
Application_Sta rt, and then saving myObject to the application object.
But later on, Application_Sta rt invariably fires again and I end up
re-creating the object, because I can not see it on the current
application object. Meanwhile the original application object still
has its own instance of my COM object, so two instances now exist but
they both enter an invalid state.

Any help would be greatly appreciated.

Nov 18 '05 #3
Bruce,

Thanks very much for the reply.

I had thought I had seen a post indicating that there is more than one
application object, which I thought explained the behavior I've been
seeing.

I've mostly been using the application with the VS.NET debugger, which
combined with the fact that this COM object only allows one instance at
a time, has been causing me all sorts of problems. In any case your
explanation of when the application starts and stops in relation to the
debugger is a big help.

Do you know if, when the server restarts the application due to the
debugger or a detected code change, the Application_End event reliably
fires? In my initial attempt to make this all work, I creted the
object in application_Sta rt and properly disposed of it in the
application_end event, but at least in debugging I still had problems
from multiple instances of the COM object.

I don't have the source code to the COM object in question and I won't
be able to get it, so modifying it at that level is not in the cards.
In fact, I've spoken to the developer of the COM object, and it was
written in VB6 as an ActiveX EXE but was not written as a singleton.

Thanks in advance for any help.
bruce barker wrote:
while there are multiple Application instantences, there is only one cache, and Application start only fires once per AppDomain.

here is the rub. asp.net will load a new appdomain for your site if it believes there are any code changes, or that the site needs recycling, or its hit the timeout. the old appdomain will stay in memory until its
serviced all of its current transactions, and run its shutdown.

while appdomains have their own memory and .net objects are distinct, com objects use the asp.net memory. you will have to write some unmanaged code to manage the com objects. the unmanged code will be called by application start, and return the handle to the com object. it internally will need to create one instance of the com object and track that its been created.
you also may be able to host the com object in com+ and make it a singleton.
-- bruce (sqlwork.com)
"SL" <sk***********@ yahoo.com> wrote in message
news:53******** *************** ***@posting.goo gle.com...
All,

As I understand it, a single application (i.e. IIS virtual directory) in ASP.NET may in fact have more than one corresponding
HttpApplication State object (more or less one per server thread, I
think). During each request, only one of these objects is exposed to the page as Page.Applicatio n. This seems to be supported by the fact that when I use the debugger, I can see the Application_Sta rt event
firing more than one time even though IIS has not been shut down in
between.

My question is this - within my application, I want to instantiate a specific COM object, and then I want to store this one instance some place where it will a) remain until IIS shuts down and b) is
accessible by all pages, during all requests, regardless of exactly
which application object is being used by each request. Due to the
way that this particular COM component was written, I can only have
one instance of the COM object in question at any time. If I try to have more than one instance exist concurently, they both enter an
invalid state and can no longer be used.

What I initially tried was instantiating my object on
Application_Sta rt, and then saving myObject to the application object. But later on, Application_Sta rt invariably fires again and I end up re-creating the object, because I can not see it on the current
application object. Meanwhile the original application object still has its own instance of my COM object, so two instances now exist but they both enter an invalid state.

Any help would be greatly appreciated.


Nov 18 '05 #4

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

Similar topics

3
3652
by: TT (Tom Tempelaere) | last post by:
Hi there, In my application I have a panel that contains a matrix of user controls. The user control is fairly simple. It merely draws a circle that represents an object in my code. The object has certain properties that can be configured, so each control has a context menu that allows such operations. However, my application requires setting properties for multiple objects at once. That would require being able to select multiple...
6
539
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by surfin it in multiple browsers simultaneously the site generates a generic runtime error after awhile. I'm thinking this has something to do with my access database and multiple connections. I'm using forms authentication with a login page. Is...
7
2161
by: jsale | last post by:
I have made an ASP.NET web application that connects to SQL Server, reading and writing data using classes. I was recommended to use session objects to store the data per user, because each user using the application needs to see their own data only. My problem is that when multiple users are in the application, when in the session object, data is fine, however as there is only one instance of the class files, when data is put into them,...
2
2102
by: Tumurbaatar S. | last post by:
ASP.NET QuickStart Tutorial says that: .... ASP.NET maintains a pool of HttpApplication instances over the course of a Web application's lifetime. ASP.NET automatically assigns one of these instances to process each incoming HTTP request that is received by the application. The particular HttpApplication instance assigned is responsible for managing the entire lifetime of the request and is reused only after the request has been...
9
2778
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and wizards. But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication. Background I have been commissioned to create a web-based application for a client. It has a formsaunthentication...
9
5405
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same for each thread, I put in Shared methods as below. It is only now that I am realizing the complexity of multiple threads accessing shared methods. And, quite honestly, I am very confused. I have tried System.Threading.Monitor.Enter, Synclock,...
0
1336
by: Sebastian Loncar | last post by:
Hi, i have two applications, which communicates very extrem together. With the IPC-Channel i receive often the messages like "all instances of the requested pipe are busy". So i want to use multiple Channels to communicate, maybe 10 Connections. For this scenario i created on each side 10 Servers and 10 Channels, each Channel has a Number in its Name(for example myserver.0 to myserver.9 and myclient.0 to myclient.9)
3
14479
by: breeto | last post by:
If you've configured .NET Remoting to use more than one channel of the same type, for example two TcpClientChannels with unique names, when you want to create a proxy to a remote object how do you specify which channel you want that proxy to use? Thanks in advance.
2
2166
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu objects). It is possible (and it's my case) that these 2 MainMenu objects use some different MenuItem objects and some identical MenuItem objects. For example, let's assume that: mainMenu1 contains miFile, miEdit, miHelp mainMenu2 contains miFile,...
0
10155
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
10095
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
9953
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
8978
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
7502
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...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.