Detect Runtime Error from another application.
I'm making an program to keep alive an server for a game. Unlucky sometimes it gets and Runtime Error and then the server stop and my program can't detect when it happen to restart the server. So I'm in need of something to detect when another application gets an Runtime Error to be able to restart it. Thank you.
Sergio FonsecaPosted Apr 24, 2008, 8:18 PM
Sorry I'm new on C# how could I detect the error on run even with that? I understood that the code you sent logs everything that happens with the application but is there a way to detect them on run to restart the application?
Bechir BejaouiPosted Apr 24, 2008, 8:14 PM
Here you an exmple of doing this add this code to your application to listen to the targeted thread or/and process
System.IO.FileStream oStream = new System.IO.FileStream(@"C:\MyJournal.txt",FileMode.OpenOrCreate);
TextWriterTraceLitener myListener = new TextWriterTraceLitener(oStream);
use Debug class if your application is in debug mode:
Debug.Listeners.Add(myListener);
use Debug class if your application is in release mode:
Trace.Listeners.Add(myListener);
After excuting the application and the error happens
move to
C:\MyJournal.txt
you'll find there all your application inforation process step by step