Winform crashes and swallows the crash log message
This is a bit annoying. I have produced this problem in a win form app that does NOTHING.
Well not nothing because then I'd not have a problem.
This is what the File->new windows forms app does:
The app has one form with two buttons. One shuts down the app (this.Close()). The other kills the app (throw new Exception()).
When I close nicely all messages are written to the log file.
When I crash the application, catch the exception, log it and then shut down I loose any log messages after the exception. This means that the very reason for the crash will not get logged. Exception messages from before the exception was thrown are present in the log.
Actually it gets weirder. If I run the app inside of Visual Studio and crash it the messages do appear in the log. But when I run the .exe outside of Visual Studio and crash the app the log does not contain the crash message.
If I do the same from a console app it works. If I do the same from a unit test it also works. Log messages appear as they should and the exception log message is written to the file.
In conclusion: Something in the run-time of running my winform app into an crash exception bugs out NLog disabling it from logging that vital final fatal exception message.
Oh - and trying to shoot off a LogManager.Flush() did not help either.
I'd love to send the code to someone if they'd like to verify.
Re: Winform crashes and swallows the crash log message
Take a look at the impact of the JIT-Debugger.... the customer machine may not have this installed (as it's part of VS) and not the runtime itself. If you just step through the code from within VS it follows the correct.. but when just run from the exe the JIT-debugger seems to intercept the catch instead.
It's not really an nlog issue, but a JIT issue IMHO.
Please let us know what you find out... it's kinda interesting.