Understanding reflection
The unit of deployment in .NET is the assembly. An assembly is a file (either an executable or a dynamic-linked library) that contains Microsoft Intermediary Language (MSIL) code, as well as metadata about the content of the assembly and, optionally, resources. Tools such as ildasm.exe
(IL Disassembler), distributed with Visual Studio; ilspy.exe
(an open-source project); or others allow you to view the content of the assembly. The following is a screenshot of ildasm.exe
that shows the chapter_11_01.dll
assembly, available with the source code of this book:
Reflection is the process of runtime type discovery and the ability to make changes to them. This means that we can retrieve information about types, their members, and attributes at runtime. This brings several important benefits:
- The ability to load assemblies dynamically during runtime (late binding...