none
App Crash with CLR20r3 RRS feed

  • Question

  • Every time I start my application, the application crash and I can see the following problems in the event viewer.

    Problem signature:

    Problem Event Name: CLR20r3

    Problem Signature 01: cadtest.exe

    Problem Signature 02: 1.0.0.0

    Problem Signature 03: 5011ecaa

    Problem Signature 04: CADTestService.service

    Problem Signature 05: 1.0.0.0

    Problem Signature 06: 505011ecaa

    Problem Signature 07: 8e

    Problem Signature 08: 1f1

    Problem Signature 09: System.AccessViolationException

    OS Version: 6.1.7601.2.1.0.256.48

    Like that.

    I search the error on google and found many similar threads, but none of them helps, can you give me some suggestions on that? Thank you very much.

    Sunday, February 21, 2016 8:02 AM

Answers

  • Hi GreeeeeeeeeeeeeD,

    For many unhandled exceptions (for example, unhandled exceptions in thread pool threads) Support Framework in version 2.0, the CLR allows most unhandled exceptions in threads to proceed naturally. In most cases, this means that the unhandled exception causes the application to terminate.

    In the application configuration file, add the following:

    <configuration>
      <runtime>
        <legacyUnhandledExceptionPolicy enabled="true" />
      </runtime> 
    </configuration>

    Use the Application.ThreadException event before the exception causes the program to exit intercept exceptions:

    [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
    public static void Main(string[] args)
    {
        Application.ThreadException += new ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException);
        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    
        Application.Run(new ErrorHandlerForm());
    }
    
    private void button1_Click(object sender, System.EventArgs e)
    {
        throw new ArgumentException("The parameter was invalid");
    }
    
    
    private void button2_Click(object sender, System.EventArgs e)
    {
        ThreadStart newThreadStart = new ThreadStart(newThread_Execute);
        newThread = new Thread(newThreadStart);
        newThread.Start();
    }
    
    
    void newThread_Execute()
    {
        throw new Exception("The method or operation is not implemented.");
    }
    
    private static void Form1_UIThreadException(object sender, ThreadExceptionEventArgs t)
    {
        DialogResult result = DialogResult.Cancel;
        try
        {
            result = ShowThreadExceptionDialog("Windows Forms Error", t.Exception);
        }
        catch
        {
            try
            {
                MessageBox.Show("Fatal Windows Forms Error",
                    "Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
            }
            finally
            {
                Application.Exit();
            }
        }
    
        if (result == DialogResult.Abort)
            Application.Exit();
    }
    
    //Since UnhandledException cannot prevent an application from terminating, thus before termination of this example simply logs the error in the application event log.
    
    private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        try
        {
            Exception ex = (Exception)e.ExceptionObject;
            string errorMsg = "An application error occurred. Please contact the adminstrator " +
                "with the following information:/n/n";
    
            if (!EventLog.SourceExists("ThreadException"))
            {
                EventLog.CreateEventSource("ThreadException", "Application");
            }
    
            EventLog myLog = new EventLog();
            myLog.Source = "ThreadException";
            myLog.WriteEntry(errorMsg + ex.Message + "/n/nStack Trace:/n" + ex.StackTrace);
        }
        catch (Exception exc)
        {
            try
            {
                MessageBox.Show("Fatal Non-UI Error",
                    "Fatal Non-UI Error. Could not write the error to the event log. Reason: "
                    + exc.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            finally
            {
                Application.Exit();
            }
        }
    }
    
    private static DialogResult ShowThreadExceptionDialog(string title, Exception e)
    {
        string errorMsg = "An application error occurred. Please contact the adminstrator " +
            "with the following information:/n/n";
        errorMsg = errorMsg + e.Message + "/n/nStack Trace:/n" + e.StackTrace;
        return MessageBox.Show(errorMsg, title, MessageBoxButtons.AbortRetryIgnore,
            MessageBoxIcon.Stop);
    }
    

    Besides this, I also searched some similar threads, please have a look

    C# windows appication Event: CLR20r3 on application start

    Windows Application has stopped working :: Event Name CLR20r3

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 22, 2016 6:37 AM