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.