473,747 Members | 2,623 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 1921
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
3651
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
2157
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
2099
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
2772
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
5404
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
1335
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
14475
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
8978
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
8818
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
9522
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9305
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
8231
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...
0
6067
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
4588
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...
0
4860
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3296
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

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.