1

We have a .NET based Windows application developed with Visual Studio 2010. This application is built with the target framework of .NET Framework 2.0. We are shipping the application with .NET 3.5 SP1 as the working platform (prerequisite). In general, this application has been running very well with most of our customers. But one of them has got a problem at the moment. The application encounters fatal error from time to time (intermittently) and is forced to shut down without throwing any error messages apart from "App has encountered a problem and needs to close. We are sorry for the inconvenience.". The only information we can get is from the Windows event viewer. The error details are as follows:

Source: .NET Runtime 2.0 Error
EventType: clr20r3,
P1: App.exe
P2: 6.0.0.0
P3: 4dee1ecd
P4: system.windows.forms
P5: 2.0.0.0
P6: 4889dee7
P7: 16cf
P8: 159
P9: system.componentmodel.win32
P10: NIL

When the application crashes, the user were performing different operations. We set up a virtual machine with the Windows XP Professional on, which is the OS our customer is using. Everything was running perfectly OK on the testing environment. We never be able to replicate this issue.

Any body has got any ideas or thoughts?

Any comments are highly appreciated.

Dan
  • 63
  • 1
  • 1
  • 7
  • You need to improve your unhandled exception handling. Write an event handler for the AppDomain.CurrentDomain.UnhandledException event and display or log the value of e.ExceptionObject.ToString(). – Hans Passant Jul 29 '11 at 15:29
  • possible duplicate of [Deciphering the .NET clr20r3 exception parameters P1..P10](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10) – Hans Passant Jul 29 '11 at 15:29

2 Answers2

2

I have seen this error (or at least one similar to it, this was a while ago) appear in the event log when a Windows forms application encounters an unhandled error ouside of the message pump - you should check to make sure that both your Main method and all background threads have try-catch blocks, (or you handle the UnhandledException event):

[STAThread]
static void Main()
{
    try
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
    catch (Exception ex)
    {
        // Log me
    }
}

Note that in example posted the above catch block would not normally be used as these methods don't usually throw exceptions, however if you have changed your UnhandledExceptionMode or do anything that might throw an exception outside of your message pump then this might give you the behaviour you are seeing.

Justin
  • 84,773
  • 49
  • 224
  • 367
2

Don`t rely on the windows log. instead right the bug your self; you can do is to handle any exceptions thrown by your application, log it, then restart your application:
So at your main:

AppDomain.CurrentDomain.UnhandledException += OnCurrentDomain_UnhandledException;

//Add these too if you are in windows forms application
Application.ThreadException += OnApplication_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

Then if exception thrown just log it, and you can also restart your application

private static void OnCurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
#if DEBUG
    System.Diagnostics.Debugger.Break();//we will break here if we are in debug mode.
#endif//DEBUG

    LogException(e);//maybe send email to you also.
    RestartTheApplication();    
}
Jalal Said
  • 15,906
  • 7
  • 45
  • 68