From Part 1 of DotNet basics videos, we understood that, compiling any .NET application would produce an assembly. Assemblies have an extension of .DLL or .EXE. For example if you compile a windows or Console application, you get a .EXE, where as when we compile a web or Class library project we get a .DLL. Please watch Part 1, if you haven't done so already.
The entire source code of a project is compiled into Intermediate Language and packaged into the assembly. A .NET assembly consists of Manifest and Intermediate language. Manifest contains metadata about the assembly like the name, version, culture and strong name information. Metadata also contains information about the referenced assemblies. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.
Some information in the assembly manifest can be modified using attributes. For example to modify the version number follow these steps
1. Expand the properties folder in solution explorer. Every project in .NET has a properties folder.
2. Open AssemblyInfo.cs file that is present under properties folder.
3. In this file, you should see AssemblyVersion attribute, which is defaulted to 184.108.40.206. Change this to 220.127.116.11 and rebuild the solution.
4. Now open the assembly using ILDASM.exe
To peek inside an assembly with ILDASM follow these steps.
1. Navigate to Visual Studio Command Prompt (Start -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Right Click on Visual Studio Command Prompt 2012 and select "Run as Administrator")
2. Once you have the "Visual Studio Command Prompt 2012" open, type in the following command and press enter
This command should open the assembly and you will find the manifest and the types (classes, structs etc..) in the assembly. At the bottom you can see the version of the assembly.
If you want to save the Intermediate Language to a text file.
1. Select File Menu from the ILDASM tool.
2. Select Dump and you will see "Dump Options Window"
3. Click OK on "Dump Options Window"
4. Now enter the file name of your choice. For this example let's enter sample and save it to the C: drive.
5. Now navigate to C: drive in windows explorer and you should see Sample.il
6. Open Sample.il with notepad and you should see assembly metadata and IL(Intermediate Language).
If you want to rebuild an Assembly from the Sample.il file we can use a tool ILASM.exe
1. Type the following command in "Visual Studio Command Prompt" and press enter
2. Now navigate to C: drive in windows explorer and you should see Sample.exe
We use ILDASM (Intermediate Language Disassembler) to peek at the assembly manifest and IL. You can also use this tool to export manifest and IL to a text file.
We use ILASM.exe (Intermediate Language Assembler) to reconstruct an assembly from a text file that contains manifest and IL.