Error clr20r3 .NET Windows Application Visual Studio 2010
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 (pr开发者_开发知识库erequisite). 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: NILWhen 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.
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.
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();
}
精彩评论