Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What runs my C# application?

Tags:

c#

clr

When developing a C# project in Visual Studio, I have three options for output type. Console Application, Windows Application, and Class Library. AFAIK, the only difference between a DLL and an EXE, is the EXE should have an entry point defined, and that is called when the file is double clicked. However, when I launch an EXE built from a Console Application, a console window is created. So obviously something is happening other than the CLR getting launched and then calling my Main method. What launches the console window? When I launch an EXE built from a Windows Application, is some other code run also, or is it just my main method?

like image 468
Ethan Reesor Avatar asked Jan 17 '26 02:01

Ethan Reesor


1 Answers

Your portable executable file(exe) will contain the information about what kind of application it is.

Subsystem flag of the IMAGE_OPTIONAL_HEADER defines what kind of user interface the application is built with.

IMAGE_SUBSYSTEM_WINDOWS_CUI defines the console application, IMAGE_SUBSYSTEM_WINDOWS_GUI defines the windows application and so on.

For more information Peering Inside the PE: A Tour of the Win32 Portable Executable File Format

like image 99
Sriram Sakthivel Avatar answered Jan 19 '26 16:01

Sriram Sakthivel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!