473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Robustly detecting an error when starting an app via code

Hi everyone,

Can anyone tell me if there is a standard way of detecting an error in a
process that I've started using the .net framework's
System.Diagnost ics.Process class?

I need to regularly call a secondary application but be able to tell if
a problem has occured with it and log the error (and then probably
restart it)

Can anyone tell me how to detect the error in the running process?

Thanks to anyone who can advise

Best regards

Simon
Sep 4 '07 #1
3 1451
Simon,

You can't do this in a generic manner. If anything, you have to have
knowledge of the process and how to retrieve any error that occurs in the
process. The only generic way of handling an error is to use the ExitCode
property on the Process class, but even then, the return values are specific
to the application being run.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Simon" <no******@hotma il.comwrote in message
news:Oc******** *****@TK2MSFTNG P06.phx.gbl...
Hi everyone,

Can anyone tell me if there is a standard way of detecting an error in a
process that I've started using the .net framework's
System.Diagnost ics.Process class?

I need to regularly call a secondary application but be able to tell if a
problem has occured with it and log the error (and then probably restart
it)

Can anyone tell me how to detect the error in the running process?

Thanks to anyone who can advise

Best regards

Simon

Sep 4 '07 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:OU******** *****@TK2MSFTNG P06.phx.gbl...
Simon,

You can't do this in a generic manner. If anything, you have to have
knowledge of the process and how to retrieve any error that occurs in the
process. The only generic way of handling an error is to use the ExitCode
property on the Process class, but even then, the return values are
specific to the application being run.
In addition to the exit code, you can capture output from a console
application, or some programs can be configured to write a log. Another
option might be to start the process under OS debug and capture
OutputDebugStri ng calls (that's what .NET's TraceListener uses to send
messages by default).
>

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Simon" <no******@hotma il.comwrote in message
news:Oc******** *****@TK2MSFTNG P06.phx.gbl...
>Hi everyone,

Can anyone tell me if there is a standard way of detecting an error in a
process that I've started using the .net framework's
System.Diagnos tics.Process class?

I need to regularly call a secondary application but be able to tell if a
problem has occured with it and log the error (and then probably restart
it)

Can anyone tell me how to detect the error in the running process?

Thanks to anyone who can advise

Best regards

Simon


Sep 5 '07 #3
Thanks guys - very much appreciated
Sep 8 '07 #4

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

Similar topics

5
12597
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that file may have been created but a crash occurred at that point in time (while it was being created), damaging the file. Now, my program which needs to read from this file, should first check that it's in good condition, and that it hasn't been...
1
7623
by: Tim Gosselin | last post by:
I am writing a tcp tunnel but cannot find a way of detecting when a socket shuts down its read end without writing to the socket. For testing the write end of the remote endpoint I just do a: if not sock.recv(buffsize) I cannot write to the socket and check if send returns 0 though, because that involves sending data out of the which may not have come in yet. When I try polling the socket with:
8
3008
by: Les Desser | last post by:
Is there any way to detect within A97 when Windows is trying to shut down, so I can close down the application gracefully? We currently have a trap in the main menu asking the user to confirm if they want to shut the application. If the user is not at his desk and power fails and the UPS instructs Windows to close, then Windows will not shut down till the Access dialog is dismissed. Result = a flat battery and a crashed PC. Thanks.
7
8194
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being shut down or restarted. At all other times, the service runs just fine. I need to either detect a logon/logoff event OR check somehow as to whether there is currently a valid logged on user. The closest I have found is ManagementEventWatcher...
1
1274
by: Sharkbait | last post by:
We are trying to record browser information when a customer comes to our site. I have been able to get most basic browser information using both asp and asp.net. The only thing I’m missing is the ability to detect plug-ins. Does anyone know how I can access the plug-in collection in IE? I have not found any clear way of doing it on the internet I’m starting to think I am headed down the wrong path. Maybe IE doesn‘t call it a plug-in...
3
3613
by: regtrashcan | last post by:
I have a webpage that detects whether Shockwave Player is installed and the version number. The javascript/vbscript that I use has worked fine until the latest release of the Shockwave Player. I am still able to detect the Shockwave Player and the version number when using Firefox/Netscape, but not with IE. I have my own detection script that I use, but I've also used the detection scripts supplied from Macromedia, but it still won't...
79
3797
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially appeared because NCSA stopped them from using "Mosaic" in the UA string. Is it some different...
1
2451
by: whitehorse | last post by:
When the warehousecontroller service is invoked, the following error message is sent to the application log: Event Type: Error Event Source: TFS Warehouse Event Category: None Event ID: 3000 Date: 4/14/2006 Time: 2:41:08 PM User: N/A
15
4233
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is testing for support of particular eventTypes - the DOM 2 Events Interface DocumentEvent says that if the eventType is not supported, it throws a DOM exception. This makes testing rather tough - if you try something like: if (document &&...
0
9498
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
10373
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
10118
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
8995
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
7519
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
6750
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.