header image ≡ Menu

Basics: Ever Wondered what is the difference between an Exe and a Dll?

An exe is an executable file which runs as a separate process and is managed by the OS. It sometimes contains a complete program. Like a Dll, an exe cannot be shared between applications. When windows loads an exe, the exe’s initialization code is responsible for creating what is called as “message pump”, nothing but a program loop which runs as long as the application is running. The message pump request messages from the operating system. Windows keep track of the application as a separate task. It allocates separate memory for both the exe and the application using that exe. The memory area in which each exe runs is called “Process Space”. In an exe, there is an entry point (There is only one single main entry). An exe is visible to the system as a regular Win32 executable. Its entry point refers to the small loader which initializes the .Net run-time and tells it to load and execute the assembly contained in the exe. When the system launches a new exe, a new process is created. The entry thread is called in the context of the main thread of that process. An exe cannot be reused. It is self executable. They can run individually.

A dll is a dynamic link library which can be used in exe files and other dlls. It is referenced or linked to exe at run-time. It is located at runtime using PATH environment variable. This enables many different programs to use this library and perform their tasks making it easier on the programmers so that they do not have to keep reinventing the wheel each time they write software. A .DLL file will contain logic that other programs will use and hence it can be shared between applications. A Dll contains compiled versions of functions that can be linked into a program. The “linking” is taken care of automatically when you compile your program. There are many entry points in a dll. The system loads the dll into the context of an existing thread. Dlls can have multiple versions and be re-used. It doesn’t have a main function and not self executable.


Source: Community discussions

You would also be interested to read –

For more related reading, have a look at these articles.

Comments on this entry are closed.

Google+