.Net Ought To Know #4 : What is the difference between an EXE and a DLL?
The main difference between an EXE and a DLL is the fact that an EXE contains instructions for the processor and has an entry point for the execution to start. In this .Net Drag and Drop world where most of the underlying tasks are taken care of for us, this is sometimes hard to see. In the classes I teach, in order to focus on the the code and not the bells and whistles, I often assign Console Applications for homework. The entry point for a console application is the Sub Main() procedure. You can see this by going to project properties and looking at the Startup object. Since a console application will create an EXE, it needs to know where to start execution.
If we change the Application type from Console Application to Class Library, you will notice that the Startup object type now says <none>. This is because a DLL cannot be executed(or loaded)directly, it can only be called by another process.
It is also interesting to note how this question relates to .Net Ought To Know #3. An EXE runs in its own address space(out-of-process) while a DLL will run in the address space of its host (in-process). If you wanted to dive deeper into this, you could load up both a DLL and EXE in ILDasm.exe and look for the <entrypoint> marker in the EXE file.
Happy Programing.
Doc
Subscribe in a reader
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.