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?
-
wouldn't this just determine what libraries are included by default? Can you add windows forms libraries to a console app and create and display a form? I know, a question in a question...ps2goat– ps2goat2014-07-15 22:41:41 +00:00Commented Jul 15, 2014 at 22:41
-
3stackoverflow.com/q/7613880Robert Harvey– Robert Harvey2014-07-15 22:41:58 +00:00Commented Jul 15, 2014 at 22:41
-
1Strongly related (see the accepted answer): what is the difference between win32 application, windows form application and console application?Frédéric Hamidi– Frédéric Hamidi2014-07-15 22:42:21 +00:00Commented Jul 15, 2014 at 22:42
-
@Robert, heh. Yours is better than mine :)Frédéric Hamidi– Frédéric Hamidi2014-07-15 22:42:58 +00:00Commented Jul 15, 2014 at 22:42
-
2@atoi, 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.Frédéric Hamidi– Frédéric Hamidi2014-07-15 23:35:00 +00:00Commented Jul 15, 2014 at 23:35
1 Answer
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.