Assembly vs DLL
A library is a collection of resources that can be used to develop applications. A library is usually made up of subroutines, functions, classes, values and types. During the linking process (usually done by a linker), libraries and executables make reference to each other. DLL files are the library files that are linked dynamically. DLL was developed by Microsoft. But due to some problems present with DLL files, Microsoft came up with Assembly file format (with the .NET framework). Assembly files are very similar to DLLs physically, but they have many internal differences.
What is DLL?
Dynamic Link Library (more commonly known as DLL) is a shared library implementation developed by Microsoft. It uses the .dll, .ocx or .drv extensions and they are used in Microsoft Windows and OS/2 operating systems. .dll is used by the regular DLL files. And .ocx extension is used by the libraries that contain ActiveX controls and .drv extension is used by legacy system driver files. The DLL file format is same as the Windows EXE files (Portable Executable files on 32-bit/64-bit Windows, and New Executable on 16bit Windows). Therefore, any combination of code, data and resources can be contained in DLL files (just like in EXE files). As a mater of fact, data files with the DLL file format are called resource DLLs. Icon libraries (with .icl extension) and font files (with .fon and .fot extensions) are examples of resource DLLs.
Components called sections make up a DLL and each section has its own attributes like read-only/writable and executable/non executable. Code sections are executable, while data sections are non executable. The code sections are shared and data sections are private. That means all processes using the DLL will use the same copy of the code, while each process will have its own copy of the data. The primary dynamic library for Windows is kernel32.dll, which contains the base functions (file and memory related functionality) on Windows. COM (Component Object Model) is the extension of DLL to OOP (Object Oriented Programming). Conventional DLLs are easier to use than COM files.
What is an Assembly?
Assembly files were introduced by Microsoft in order to solve several problems present with DLL files. Assembly files were introduced with the Microsoft .NET framework. An executable logical unit of functionality is called an Assembly. Assemblies are executable under .NET CLR (Common Language Runtime). Physically, assemblies exist as EXE or DLL files. But, they are very different to Microsoft Win32 DLLs, internally. An assembly file is made up of a manifest, metadata, MISL (Microsoft Intermediate Language code) and other resources. An assembly is self-describing. The manifest contains the information such as name, version, culture, strong name, files list, types and dependencies. MISL code is executed through CLR (it cannot be directly executed).
What is the Difference between Assembly and DLL?
DLL is a dynamically linked library. Although, assemblies are physically equal to DLLs, they are very different internally. It is not possible to maintain consistency between a set of DLLs, but the CLR can maintain consistency between a set of assemblies, because assemblies are self-describing (they contain the list of dependencies internally). Unlike for DLLs, versioning information is enforced for assemblies (by the CLR). Side-by-side deployment (different applications using different versions) is possible with assemblies.