Sunday, 30 December 2012 13:56

how to track errors if any when software starts

Written by 
Rate this item
(0 votes)

when you run your c# application there may be
unknown errors for various reasons.you can
view those errors to correct later.
better way is to store those errors in a online
file using webservice automatically.

following codes show how -

in your main form under Main method add the lines-

[STAThread]
static void Main()
{
Application.ThreadException += new System.Threading.
ThreadExceptionEventHandler(Application_ThreadException);
}

static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
{
class_Error ErrorLog = new class_Error();
ErrorLog.SendtoWebService(e.ToString());
}

here SendtoWebService(e.ToString() method
of error class 'class_Error' handles the
rest to add the error message in a online file
using webservice.

Read 1352 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments