Join Ted Neward for an in-depth discussion in this video Ildasm.exe, part of CLR Reflection for Developers.
- [Narrator] One of the tools you're going to find invaluable to use as you play around with the .net reflection APIs will be utility that ships with the .net STK called Ildasm, it's the IL Disassembler. This is a utility that can take a compiled .net assembly, and effectively pick it apart and all you to see the actual bite code, the intermediate language or common intermediate language as it's more commonly known and see the assembly language, if you will, of the .net environment. This will be important in many cases because in some scenarios, you will be able to know the types ahead of time but you won't have compiled time access to them.
Ildasm will let you look at what you are going to be working with and be able to discover the names and so forth that are there, but it can also be useful as a verification mechanism to verify that what you're looking at via reflection is, in fact, the same thing that Ildasm is seeing as well. If there's ever a discrepancy there, then obviously, something's wrong with your code. We're going to look at Ildasm really quickly. As a matter of fact, one of the things that we're going to do as we build out some of these reflection examples is we're going to build a utility similar in some respects to Ildasm that will be displaying this information at run time as opposed to Ildasm which uses the unmanaged metadata APIs to be able to get at this stuff.
We're going to be using the .net reflection APIs to get at the same information, just through two different paths.
- Working with the IL Disassembler (Ildasm)
- Namespaces and types
- Type API
- Properties API
- MethodBase and MethodInfo API
- Constructors API
- Fields API
- Constructing objects
- Accessing properties and fields
- Invoking methods