tags:

views:

54

answers:

1

I'm using C#/WPF, and generated a console programmatically using the WinAPI's Alloc/FreeConsole. When this is done, the standard System.Console class interacts wih it fine. Except, when you close the console by clicking the X rather than using FreeConsole(), it closes the rest of the app too. I'm using .NET 4- how can I override this behaviour?

A: 

This is just a guess, and it could be completely off, but does it have anything to do with Application.Current.ShutdownMode? Perhaps Application.Current.MainWindow is being set to the console, and ShutdownMode causes the application to terminate when the console window is closed?

mattjf
Sorry about the delay, I got switched to another project. I'll get back to you soon.
DeadMG
@mattjf: Sorry- doesn't work. I set the MainWindow to the primary window and set ShutdownMode to OnMainWindowClose, but the behaviour remains.
DeadMG