Winform crashes and swallows the crash log message

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Winform crashes and swallows the crash log message

noopman
Hi!

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.

How should I debug and solve this?

Cheers,

Magnus
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

Jarek Kowalski
Administrator
Can you send me a repro? [hidden email]
Are you using NLog 1.0 or 2.0 ?
 
Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

noopman
Thanks for a speedy reply!

I'm using NLog 1.0

Here is my extremely simple code:

Test_nlog.zip

The error occurrs when running the winform app by double-clicking the .exe and then hitting the Die! button. There should be a log message regarding the error in the log file. But there isn't.

Cheers,

M.
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

Jarek Kowalski
Administrator
I looked at your app and I don't think I fully undestand what is the expected behavior.

I have some ideas about what may be going on and would like to chat with you on MSN, Skype or Google Talk. Can you send me your IM address to jaak@jkowalski.net.

Thanks,

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

noopman
Hmmm... for some reason I am not getting the same problem at home as I do on my customer's work environment. I will have to test this further and will be back with the results.

Thanks for looking at this!

M.
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

Jason LaFlair
Administrator
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.
Reply | Threaded
Open this post in threaded view
|

Re: Winform crashes and swallows the crash log message

noopman
Thanks Jason I'll try that and I think you're right.

I had no idea but it seems that this issue only occurs on my work machine. No other PCs I've tried it on has the same issue.

Thereby we can certainly close this issue.

@Jarek: Thanks to you too.

M.