Unknown Hard Error message is shown when application exits using a call to Environment.FailFast

StackOverflow https://stackoverflow.com/questions/13314945

  •  28-11-2021
  •  | 
  •  

سؤال

We have a C# application that hooks up to AppDomain.UnhandlerExceptions and listens to any unhandled exceptions in the application. Once there is a unhandled exception, it shows an error message to the user and kills the application via a call to Environment.FailFast.

The issue is that on some machine this causes a "Unknown Hard Error" message to be shown to the user and the application does not exit till we click "Ok".

The OS is Windows 7 x64 with .NET 4 application.

هل كانت مفيدة؟

المحلول

We contacted Microsoft and it turned out that it was because Windows Error Reporting Service was disabled on the Windows machine.

The call flow is like this:

  1. Application terminates it self by calling Environment.FailFast.
  2. CLR checks if any debugger has registered to handle the exception. Incase a debugger is registered, the exception is handled by the debugger.
  3. Incase there are no debuggers, CLR tries to pass the exception on to the OS. It tries to start the Windows Error Reporting Service and pass the exception to it.
  4. Incase it fails to start Windows Error Reporting Service, it queues an Unknown Hard Error in the kernel and the Unknown Hard Error message is shown to the user.

نصائح أخرى

Issue Solved for me after doing these changes! It might be the DLL issue, Do check before start compiling. 1.check platform target should be in x64 in either debug or Release mode. 2.then save it and start debugging and also better try and catch in the code and it is good practice

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top