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

Resource Monitor/ relaunching an application that crashed

Hi all,

I am writing a proxy server in C# and it crashes (fairly) often. I have my code in a try catch block and I catch all the types of exceptions it throws. But I am looking for a clever way to relaunch the program when this happens as it dies.

It is a C# Console Application in .NET 2005.

Any help is appreciated.

Thanks alot,
Nick
Jul 23 '07 #1
7 1215
Plater
7,872 Expert 4TB
You really should be working to solve the problems that cause it to crash.
There's really not any reason a thrown error should stop your program, you just need to put try catch blocks in correct places.

As for your question though, if it's installed as a windows service, the service controls (services.msc) has a whole section on "what to do if program is stopped" (reboot pc, reload program, do nothing, etc)
Jul 23 '07 #2
Its not installed as a windows service, just a console application I want to have constantly running. I definitely do want to try to avoid these exceptions but in the mean time would like to find the best practice on how to do this.

When I catch the error, I try to create a new instance of the class but it doesn't start correctly. Could you tell me the best way to re-instantiate the object? The catch is made at the end of the code...

Thanks in advance
Nick
Jul 23 '07 #3
Plater
7,872 Expert 4TB
Can you shrink the try-catch blocks to encapsulate smaller bits of code?
For instance if I have a socket listening for requests, I would put that in a try-catch. BUT I would also put the code where I handle communication with a socket connecting to me in a different, smaller, try-catch block. Then you can perhaps recover from the error without having to restart from the begining. (For instance when a user kills a connection before I am done responding, it throws an IOException, but it doesn't effect my listener socket)


What you could try and do is make a tiny little program, thats sole job is too look at the proccesses that are running and if your application isn't running, re-open it. You could always close that 2nd little application when you ACTUALLY want your program to stop.
Jul 23 '07 #4
Plater,

This idea is one that I've definitely had but not sure how to implement. Do you have any idea to access the processes (like Task Manager), see if it is running or not and if not relaunch the app?

I'll try putting smaller try/catches too.

Thanks again
Nick
Jul 23 '07 #5
Plater
7,872 Expert 4TB
It's all in .NET already :-)
Check on this:
http://msdn2.microsoft.com/en-us/library/1f3ys1f9.aspx
Or maybe even more usefull:
http://msdn2.microsoft.com/en-us/lib...sesbyname.aspx
Jul 23 '07 #6
thanks alot plater...i think this will work just great
Jul 23 '07 #7
TRScheel
638 Expert 512MB
Could you perhaps post your code? I for one am curious as to what code you have that is causing these issues.
Jul 23 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gary Whitten | last post by:
We have a JDBC project that works with SQLServer, along with other DBs. During development, we noticed that resource useage on SQLServer seemed to grow steadily - Processes, Process Locks and/or...
2
by: Mr.Tickle | last post by:
Is it possible to determine when and what application crashed from within C# ? I want to send data over UDP to an application socket, and after that I want to determine whether its crashed or...
0
by: Kevin P | last post by:
Hi News Group, In an application written in C# and VS.Net using Dotnet Framework 1.1.4322 on XP and Win 2000 machines, we randomly get the error "Failed to load resources from resource file....
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
4
by: yoyo | last post by:
Is there any way in DB2 to get the exact command. I have an event monitor I created for statments, and all the statment values are filled with a question mark. I was using this at another site...
1
by: p175 | last post by:
Anyone got any ideas as to what could be causing these errors ? ESE 8.2.2 on Win2k server FP4 2005-08-16-21.46.53.554000-240 I1202H313 LEVEL: Warning PID : 2464 ...
10
by: RobinS | last post by:
Hello to all, and happy new year! I have this application that someone wrote that I'm sort of checking out. The forms look fine in design mode, but when I run the application, it crops off the...
4
by: onedbguru | last post by:
DB2Connect Informational tokens are "DB2 v8.1.0.96", "s050811", "U803921", FixPak "10". I am getting txxxxxx.0000 files approximately every 14 minutes that look like: <Trap> <Header> DB2...
21
by: DiAvOl | last post by:
Hello, I am using a simple php server that I wrote and have some questions related to the resource id's. When a new client connects to the server or the server opens a file the Resource id...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.