Using code to hook the console close event from this thread, I sometimes get a NullReferenceException
with no stacktrace (most of the times I don't). It happens in both release and debug and "break when an exception is thrown" doesn't help (it breaks, but the stack trace is still empty). I never get this exception when I exit my application normally (which is hitting enter and thus releasing a Console.ReadLine
). The Application event log has 2 entries:
Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException Stack:
And:
Faulting application name: Gateway.exe, version: 1.0.0.0, time stamp: 0x4e284101 Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 Exception code: 0xc0000005 Fault offset: 0x004d41ce Faulting process id: 0xf00 Faulting application start time: 0x01cc47b827e19a6e Faulting application path: C:\dev\MyApp.exe Faulting module path: unknown Report Id: 689c1caa-b3ab-11e0-ba1b-00247e777f12
Google has revealed some bugs and issues with SetConsoleCtrlHandler
, so I'm wondering if this is a lost battle.