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

Application restart...

In a FMain of below application I'm throwing an Exception.
It's catched by a catch section and application restarts.
But in a reastarted application try section doesn't work no longer.
Error throwed by FMain is no longer catched and causes a
last chance CLR erception handler. Why?

[STAThread]
public static void Main(string[] pStartupParameters)
{
try
{
FMain main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Restart();
}
}
Nov 16 '05 #1
5 11582
Just try to change your code like the following.

[STAThread]
public static void Main(string[] pStartupParameters)
{
FMain main = null;
//
try
{
main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Restart();
}
}
Nov 16 '05 #2
Doesn't work ...

"Oleg Yevsyukov" <eo*@altc.lg.ua> wrote in message
news:08****************************@phx.gbl...
Just try to change your code like the following.

Nov 16 '05 #3
As Another Poster pointed out, the call to Restart is in the catch block.
I'd change the code to this...

bool _wantsToExit;
[STAThread]
public static void Main(string[] pStartupParameters)
{
done = false;
while ( !done )
{
try
{
FMain main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
if ( _wantsToExit )
done = true;
}
}
}

where "_wantsToExit" is a boolean set somewhere else in your application
when the user is done and wants to exit the app.
"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
In a FMain of below application I'm throwing an Exception.
It's catched by a catch section and application restarts.
But in a reastarted application try section doesn't work no longer.
Error throwed by FMain is no longer catched and causes a
last chance CLR erception handler. Why?

[STAThread]
public static void Main(string[] pStartupParameters)
{
try
{
FMain main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Restart();
}
}

Nov 16 '05 #4
You'r code works but ... every secound time.
I mean after first restart works , secound doesn't , third works , fouth
doesn't ... and so one ...
As Another Poster pointed out, the call to Restart is in the catch block.
I'd change the code to this...

Nov 16 '05 #5
Without seeing your code it's impossible to know why. The restart routine
must have problems.

"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:e5*************@TK2MSFTNGP12.phx.gbl...
You'r code works but ... every secound time.
I mean after first restart works , secound doesn't , third works , fouth
doesn't ... and so one ...
As Another Poster pointed out, the call to Restart is in the catch block. I'd change the code to this...


Nov 16 '05 #6

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

Similar topics

8
by: Google Mike | last post by:
I need an Application object replacement. I was creating my own using shared memory -- shm* API in PHP. I was doing fine for 6 months until it just got too fat, I guess, and the RH9 Linux server...
1
by: localhost | last post by:
In the Application_OnStart, I make some data calls and place the results in the HTTP cache. Sometimes, the database is not available when the application starts up, so I want to sleep for 20...
3
by: Jiong Feng | last post by:
Hi, I have a question. WE have a web application in web root. And also we have a virtual directory library application. If we change root web.config, the root application will restart....
3
by: Pint | last post by:
I would like to know if there is a programatic way to force the Application object to restart. I have a hosted website where I will be unable to control the webserver (eg:iisreset), and I would...
3
by: ad | last post by:
I want to renew all values of Application and Session. How can I restart application in program?
3
by: Glyn Simpson, MVP | last post by:
Hi I've got an ASP.NET 2.0 application, and I would like to catch the scenario of when I get a certain number of application errors, I want to restart the application (similar to 'touching'...
3
by: Ray Booysen | last post by:
In our application, we merge documents for our clients. The directory structure is as follows: webroot ->bin ->Documents ->Company -> Company X
1
by: Brian Simmons | last post by:
Hi All, I know that if you modify the web.config file or any file in the App_Code subfolder, that ASP.net 2.0 will "restart" the application (i.e. clear out any sessions, etc...). Are there...
8
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
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: 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: 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,...
0
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...
0
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...

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.