Tuesday, April 26, 2005

Hansleman's List: DLLs & EXEs

More from Scott Hansleman's list of what great developers should know: What is the difference between an EXE and a DLL? DLLs contain resources referred to at compile time but called at run time. EXEs are standalone units. (On a side note, static libraries hold resources which are pulled into the target at compile time.) DLL resources can be shared by multiple calling software units. More importantly (to me), DLLs are abstracted out from the calling code. Code using a DLL doesn't have to be recompiled if a new version of a DLL comes out with changes to the non-public implementation, e.g. bugfixes, performance or stability enhancements, etc. One problem with DLLs, particularly before .NET: DLL Hell.

2 comments:

Anonymous said...

One other difference: an EXE has an entrypoint statement in its IL, DLLs do not.

For instance, create a WinForms project and compile it to get the EXE. Now change the project output type to Class Library to compile it into a DLL. Then compare the EXE and the DLL with ILDASM. The only difference is that in the IL of the EXE, you'll see an execution statement ".entrypoint" (without the quotation marks) near the top, while it's missing from the DLL.

This is the primary reason EXEs can run on their own but DLLs can't.

Jim Holmes said...

Great feedback, Dave. I'd meant to write that "EXEs are standalone executable units", but that's still not as detailed as your point.

Thanks!

(Nice to see someone other than my Mom reading my blog.)

Subscribe (RSS)

The Leadership Journey