473,787 Members | 2,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application Start

Hi , it´s me again.

I will take another way because yesterday I make a question and,
probably I didn´t make myself clear so you didn´t understand my question.

I want to know if there is any way to register a method to the
Application Start event. I know there is one way, in Global.asax writing
code in

Application_Sta rt

but this way is not possible for me because I need to do it without
implementing those methods in global.asax

What i need is something like:

AnyDotNetFramew orkClass.Applic ationStart += new EventHandler(My _Method);

Do you know if ApplicacionStar t event is declared somewhere on the
framework so I can register to it?
Thanks in advance

Fernando Arámburu
Nov 19 '05
16 3155
Ah, I wasn't aware you also needed Session_Start semantics -- your original
post didn't mention this at all.

What is it that you need to do at application startup?

As for the Session_Start, you may be out of luck given ASP.NET's implementation
that calls Session_Start in global.asax.

-Brock
DevelopMentor
http://staff.develop.com/ballen
And where am I working with Application Start and Session Start? I
mean, you are talking about one-time initialization that is completely
different from what i need. I need to some things when Application
Start and when Session Start.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:19******** **************@ msnews.microsof t.com...
Why can't you just have a type initializer (static constructor)? This
is an easy way to get one-time initilization semantics.

public class MyClass
{
static MyClass()
{
// do your one-time init here
}
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi , it´s me again.

I will take another way because yesterday I make a question and,
probably I didn´t make myself clear so you didn´t understand my
question.

I want to know if there is any way to register a method to the
Application Start event. I know there is one way, in Global.asax
writing code in

Application_Sta rt

but this way is not possible for me because I need to do it without
implementing those methods in global.asax

What i need is something like:

AnyDotNetFramew orkClass.Applic ationStart += new
EventHandler(My _Method);
Do you know if ApplicacionStar t event is declared somewhere on the
framework so I can register to it?
Thanks in advance
Fernando Arámburu


Nov 19 '05 #11
I need to load some things to the Application object collection.I need to
create some object and put the most important one on the Application objects
collection so I can get it on every request.

I don´t understand what you say about Session_Start and out of luck ......
Can you say that in other words?
Just one thing, I can't touch Global.asax file because I need to compile
what I´m doing an generate a closed dll so Global.asax file can not be
included. The only thing I can do with Global.asax is that Global class
defined there inherits from one MyHttpApplicati on written by me and that
MyHttpApplicati on inherits from original System.Web.Http Application

Thanks in advance.

Fernando Arámburu
"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:20******** **************@ msnews.microsof t.com...
Ah, I wasn't aware you also needed Session_Start semantics -- your original post didn't mention this at all.

What is it that you need to do at application startup?

As for the Session_Start, you may be out of luck given ASP.NET's implementation that calls Session_Start in global.asax.

-Brock
DevelopMentor
http://staff.develop.com/ballen
And where am I working with Application Start and Session Start? I
mean, you are talking about one-time initialization that is completely
different from what i need. I need to some things when Application
Start and when Session Start.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:19******** **************@ msnews.microsof t.com...
Why can't you just have a type initializer (static constructor)? This
is an easy way to get one-time initilization semantics.

public class MyClass
{
static MyClass()
{
// do your one-time init here
}
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi , it´s me again.

I will take another way because yesterday I make a question and,
probably I didn´t make myself clear so you didn´t understand my
question.

I want to know if there is any way to register a method to the
Application Start event. I know there is one way, in Global.asax
writing code in

Application_Sta rt

but this way is not possible for me because I need to do it without
implementing those methods in global.asax

What i need is something like:

AnyDotNetFramew orkClass.Applic ationStart += new
EventHandler(My _Method);
Do you know if ApplicacionStar t event is declared somewhere on the
framework so I can register to it?
Thanks in advance
Fernando Arámburu


Nov 19 '05 #12
Why does your application wide data need to be in the ASP.NET Application
object? If you can't find a workaround to your problem, keeping that data
in static variables will have the same effect.

So you do have control over the global.asax? Meaning, you can specify the
Inherits directive? If so, then you can do these things you're talking about
-- in your HttpApplication derived class, add Session_Start and whatever
else you need. Didn't you try this already? I don't have the original post,
so my apologies if you've already mentioned that.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I need to load some things to the Application object collection.I need
to create some object and put the most important one on the
Application objects collection so I can get it on every request.

I don´t understand what you say about Session_Start and out of luck
......
Can you say that in other words?
Just one thing, I can't touch Global.asax file because I need to
compile
what I´m doing an generate a closed dll so Global.asax file can not be
included. The only thing I can do with Global.asax is that Global
class
defined there inherits from one MyHttpApplicati on written by me and
that
MyHttpApplicati on inherits from original System.Web.Http Application
Thanks in advance.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:20******** **************@ msnews.microsof t.com...
Ah, I wasn't aware you also needed Session_Start semantics -- your

original
post didn't mention this at all.

What is it that you need to do at application startup?

As for the Session_Start, you may be out of luck given ASP.NET's

implementation
that calls Session_Start in global.asax.

-Brock
DevelopMentor
http://staff.develop.com/ballen
And where am I working with Application Start and Session Start? I
mean, you are talking about one-time initialization that is
completely different from what i need. I need to some things when
Application Start and when Session Start.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:19******** **************@ msnews.microsof t.com...

Why can't you just have a type initializer (static constructor)?
This is an easy way to get one-time initilization semantics.

public class MyClass
{
static MyClass()
{
// do your one-time init here
}
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hi , it´s me again.
>
> I will take another way because yesterday I make a question and,
> probably I didn´t make myself clear so you didn´t understand my
> question.
>
> I want to know if there is any way to register a method to the
> Application Start event. I know there is one way, in Global.asax
> writing code in
>
> Application_Sta rt
>
> but this way is not possible for me because I need to do it
> without implementing those methods in global.asax
>
> What i need is something like:
>
> AnyDotNetFramew orkClass.Applic ationStart += new
> EventHandler(My _Method);
> Do you know if ApplicacionStar t event is declared somewhere on the
> framework so I can register to it?
> Thanks in advance
> Fernando Arámburu


Nov 19 '05 #13
> Why does your application wide data need to be in the ASP.NET Application
object? If you can't find a workaround to your problem, keeping that data
in static variables will have the same effect.
The problem with static variables is that initialization ocurrs with the
first call to an object of this class and I want to load those object when
the application start. Even though, for now is a good solution.
So you do have control over the global.asax? Meaning, you can specify the
Inherits directive? If so, then you can do these things you're talking about -- in your HttpApplication derived class, add Session_Start and whatever
else you need. Didn't you try this already?.
I tried this solution. The problem I found with this is that if I use
Session_Start method (just for example I put Session_Start, with
Application_Sta rt is the same problem) then programmers can´t write on their
Session_Start method of the Global class, because I have override their
Session_Start method.
Do you understand what I try to say?

Do you have any idea of how I can do that in that intermediate class
MyHttpApplicait on?
I don't have the original post, so my apologies if you've already mentioned that
Don´t worry about the originial post and thanks a lot for answer,

Fernando Arámburu

-Brock
DevelopMentor
http://staff.develop.com/ballen
I need to load some things to the Application object collection.I need
to create some object and put the most important one on the
Application objects collection so I can get it on every request.

I don´t understand what you say about Session_Start and out of luck
......
Can you say that in other words?
Just one thing, I can't touch Global.asax file because I need to
compile
what I´m doing an generate a closed dll so Global.asax file can not be
included. The only thing I can do with Global.asax is that Global
class
defined there inherits from one MyHttpApplicati on written by me and
that
MyHttpApplicati on inherits from original System.Web.Http Application
Thanks in advance.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:20******** **************@ msnews.microsof t.com...
Ah, I wasn't aware you also needed Session_Start semantics -- your

original
post didn't mention this at all.

What is it that you need to do at application startup?

As for the Session_Start, you may be out of luck given ASP.NET's

implementation
that calls Session_Start in global.asax.

-Brock
DevelopMentor
http://staff.develop.com/ballen
And where am I working with Application Start and Session Start? I
mean, you are talking about one-time initialization that is
completely different from what i need. I need to some things when
Application Start and when Session Start.

Fernando Arámburu

"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:19******** **************@ msnews.microsof t.com...

> Why can't you just have a type initializer (static constructor)?
> This is an easy way to get one-time initilization semantics.
>
> public class MyClass
> {
> static MyClass()
> {
> // do your one-time init here
> }
> }
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>> Hi , it´s me again.
>>
>> I will take another way because yesterday I make a question and,
>> probably I didn´t make myself clear so you didn´t understand my
>> question.
>>
>> I want to know if there is any way to register a method to the
>> Application Start event. I know there is one way, in Global.asax
>> writing code in
>>
>> Application_Sta rt
>>
>> but this way is not possible for me because I need to do it
>> without implementing those methods in global.asax
>>
>> What i need is something like:
>>
>> AnyDotNetFramew orkClass.Applic ationStart += new
>> EventHandler(My _Method);
>> Do you know if ApplicacionStar t event is declared somewhere on the
>> framework so I can register to it?
>> Thanks in advance
>> Fernando Arámburu


Nov 19 '05 #14
> The problem with static variables is that initialization ocurrs with
the first call to an object of this class and I want to load those
object when the application start. Even though, for now is a good
solution.
Are you sure you need it to run immediaetly when the app starts up and can't
wait until the first time you need this application wide data? I'd imagine
in 90% of the cases the difference between the two (time-wise) won't be a
whole heck of a lot... But of course it's not called until the first time
it's requested... which as I mentioned before, is acceptable in many scenarios.
The only sort of scenario where I don't see this being acceptable is where
your Application_Sta rt needs (or the equivalent thereof) needs to push some
information out of the application such as sending an email, or going out
to the database to log that the application has started, or write to the
event log, etc... So yeah, those scenarios it's not the right approach for.
But if what you're doing is simply preloading and/or initializing app-wide
data, then the static ctor should be fine. Anyway, it's your app, so you
know best which of these approaches is right for you.
I tried this solution. The problem I found with this is that if I use
Session_Start method (just for example I put Session_Start, with
Application_Sta rt is the same problem) then programmers can´t write on
their
Session_Start method of the Global class, because I have override
their
Session_Start method.
Do you understand what I try to say?
Do you have any idea of how I can do that in that intermediate class
MyHttpApplicait on?


It sounds like you're going to have to build your own publish/subscribe eventing
mechanism for these notifications to allow the flexiblity you have been talking
about.

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #15
Hi again,

Thanks very much for all the answers.

About the first point of the conversation, you are probably on the right
way. I mean, I want to do it on the Application Start but I think that I can
run that script as static so thanks a lot.

About the second point, yes, you are completelly right. It sounds like I
will have to build my own publish/subscribe eventing mechanism for these
notifications to allow the flexiblity I have been talking about.

Thanks a lot again and I wish I could help you in something
bye for now.

Fernando Arámburu
PS: I put on my favourites your blog so I start reading something about
ASP.NET 2.0 ;)
"Brock Allen" <ba****@NOSPAMd evelop.com> escribió en el mensaje
news:21******** **************@ msnews.microsof t.com...
The problem with static variables is that initialization ocurrs with
the first call to an object of this class and I want to load those
object when the application start. Even though, for now is a good
solution.
Are you sure you need it to run immediaetly when the app starts up and

can't wait until the first time you need this application wide data? I'd imagine
in 90% of the cases the difference between the two (time-wise) won't be a
whole heck of a lot... But of course it's not called until the first time
it's requested... which as I mentioned before, is acceptable in many scenarios. The only sort of scenario where I don't see this being acceptable is where
your Application_Sta rt needs (or the equivalent thereof) needs to push some information out of the application such as sending an email, or going out
to the database to log that the application has started, or write to the
event log, etc... So yeah, those scenarios it's not the right approach for. But if what you're doing is simply preloading and/or initializing app-wide
data, then the static ctor should be fine. Anyway, it's your app, so you
know best which of these approaches is right for you.
I tried this solution. The problem I found with this is that if I use
Session_Start method (just for example I put Session_Start, with
Application_Sta rt is the same problem) then programmers can´t write on
their
Session_Start method of the Global class, because I have override
their
Session_Start method.
Do you understand what I try to say?
Do you have any idea of how I can do that in that intermediate class
MyHttpApplicait on?
It sounds like you're going to have to build your own publish/subscribe

eventing mechanism for these notifications to allow the flexiblity you have been talking about.

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #16
If you are developing an extensible framework, perhaps you could write
your own Global.asax class with protected Application_Sta rt and
Session_Start members so that when your users inherit from your global
class, they can override your App_start and Ses_start methods as
needed, calling base.app_start or base.ses_start as needed.

This seems to be the way many OO frameworks are designed.

Alternatively, build your own App_start and Ses_start methods and
expose events that your users can hook into so that they don't need to
call these methods directly. This would seem to let you control the
timing of whether your method or theirs gets executed first...

Nov 19 '05 #17

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

Similar topics

12
2954
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am starting is that it has a welcome window first which gets displayed and then the real windows after a while,in other words it means that the process name is the same, but the handle I need to retrive is the one from the final window and not the...
6
20087
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
2
3884
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have an exe application that I want to start remotely.Once I start the application, I want to press ok to that application. To start the application, I did Process.start("C://test/app.exe"). I am writing this code in a C# web application, famework 1.1 How can I press ok to that started application. Any help will be apprecaited
0
1545
by: Cramer | last post by:
Using ASP.NET 3.5: Can a custom HTTP Module be used to register for the Application_Start event? Or _must_ I use Global.asax to work with Application.Start? I understand that I can use a custom HTTP Module to register for other pipeline events (like Application.BeginRequest), but I was told that the only place that I can set up an event handler for Application.Start is in Global.asax. My preference would be to register an HTTP Module...
0
1023
by: Cramer | last post by:
Using ASP.NET 3.5: Can a custom HTTP Module be used to register for the Application_Start event? Or _must_ I use Global.asax to work with Application.Start? I understand that I can use a custom HTTP Module to register for other pipeline events (like Application.BeginRequest), but I was told that the only place that I can set up an event handler for Application.Start is in Global.asax. My preference would be to register an HTTP Module...
0
9655
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
10363
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...
0
9964
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...
1
7517
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
6749
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
5398
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...
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.