Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:56:23+00:00 2026-06-04T03:56:23+00:00

I have a C# WPF program using AciveX objects and providing WCF service. So

  • 0

I have a C# WPF program using AciveX objects and providing WCF service. So there are many threads, many calls to unmanaged code. Sometimes under full load application crashes. I am investigating the problem – and it looks like problem is somewhere in ActiveX, which I can not change. Anyhow I need a way to restore program after crash. As for now I have found solution:

public partial class App : Application
 {
    private static readonly Logger log = LogManager.GetCurrentClassLogger();

    bool isClosing = false;


    [System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptionsAttribute]
    void D_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        log.FatalException("Error UnhandledException ", (Exception)e.ExceptionObject);
        MonitoringSvc.host.Close();
        log.Info("Restarting");
        if (!isClosing)
        {

            System.Windows.Forms.Application.Restart();
            System.Windows.Application.Current.Shutdown();
        }
    }


    private void Application_Startup(object sender, StartupEventArgs e)
    {
        AppDomain D = AppDomain.CurrentDomain;
        D.UnhandledException += new UnhandledExceptionEventHandler(D_UnhandledException);
    }

    private void Application_Exit(object sender, ExitEventArgs e)
    {
        isClosing = true;
    }
}

Program restarts on unhandled exception (on simulated for sure). But old copy stays unclosed with system message “program terminated Unexpectedly”. Program does not interact with user most time so nobody can close that message to close the program. The question is how to silently close that old windows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:56:25+00:00Added an answer on June 4, 2026 at 3:56 am

    Here is solution how to disable windows appearing on program crash. Not only WER, because even with WER disabled other window is shown (asking to close or debug program).

        [DllImport("kernel32.dll", SetLastError = true)]
        static extern int SetErrorMode(int wMode);
    
        [DllImport("kernel32.dll")]
        static extern FilterDelegate SetUnhandledExceptionFilter(FilterDelegate lpTopLevelExceptionFilter);
        public delegate bool FilterDelegate(Exception ex);
    
        App()
        {
            FilterDelegate fd = delegate(Exception ex)
            {
                return true;
            };
            SetUnhandledExceptionFilter(fd);
    
            SetErrorMode(SetErrorMode(0) | 0x0002 );
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c# program using WPF. I have it that when you press
I have WPF Form which has many buttons with the same code. Appearance of
I'm new to using WPF. I have the following program I want to create:
I have a simple WPF program using the Master-Detail UI pattern, where the Detail
I am writing a WPF program in C# in which I have a ListView
I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX
Im using prism 4.0, wpf, I create RegionAdapter for devx DocumentGroup. I have a
I have a WPF program with two listviews which display information from two different
I have created a wysiwyg editor as a standard C# program using the windows
I am using C# in Visual Studio 2008 and I have install the WPF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.