Reputation: 506
Imagine when a .NET application starts after building, either Console or WinForm. Beside the complie-time flags like /subsystem
, /out
, ... how does the operating system (currently Windows) or the .NET virtual machine (I don't know which happens to catch the running application, first) decide which one of the window-systems to run and what does that do when it wants to run the desired system?
Upvotes: 4
Views: 4181
Reputation: 13286
I see the question has been updated to reflect this comment solution by Frédéric Hamidi, but to adhere to the Q&A format of Stack Overflow, I'm admitting this as an answer with the Community Wiki flag set, as per "Question with no answers, but issue solved in the comments (or extended in chat)."
There is a flag. In the executable file itself, somewhere in the PE header. That flag is set at build time and indicates the subsystem the application wants to run under (GUI or console). The loader reads that flag and sets up a console accordingly. This predates .NET -- the CLR does not bring anything new to the picture here.
Upvotes: 2