CHAPTER 18 UNDERSTANDING CIL AND THE ROLE OF DYNAMIC ASSEMBLIES
The one opcode that is important to point out is .entrypoint. Recall from the discussion earlier in
this chapter that this opcode is used to mark which method of an *.exe functions as the entry point of
the module. In fact, given that .entrypoint is how the CLR identifies the initial method to execute, this
method can be called anything, although here you are using the standard method name of Main(). The
remainder of the CIL code found in the Main() method is your basic pushing and popping of stack-based
values.
Do note, however, that the creation of a CILCar object involves the use of the .newobj opcode. On a
related note, recall that when you want to invoke a member of a type using raw CIL, you make use of the
double-colon syntax and, as always, make use of the fully qualified name of the type. With this, you can
compile your new file with ilasm.exe, verify your assembly with peverify.exe, and execute your
program. Issue the following commands within your command prompt:
ilasm CarClient.il
peverify CarClient.exe
CarClient.exe
Source Code The CilCars example is included under the Chapter 18 subdirectory.
Understanding Dynamic Assemblies
To be sure, the process of building a complex .NET application in CIL would be quite the labor of love.
On the one hand, CIL is an extremely expressive programming language that allows you to interact with
all of the programming constructs allowed by the CTS. On the other hand, authoring raw CIL is tedious,
error-prone, and painful. While it is true that knowledge is power, you might indeed wonder just how
important it is to commit the laws of CIL syntax to memory. The answer is, “It depends.” To be sure,
most of your .NET programming endeavors will not require you to view, edit, or author CIL cod K