Skip to main content

Understanding CIL and the Role of Dynamic Assemblies

  • Chapter
Book cover Pro C# 2005 and the .NET 2.0 Platform
  • 319 Accesses

Summary

This chapter provided an overview of the syntax and semantics of CIL. Unlike higher-level managed languages such as C#, CIL does not simply define a set of keywords, but provides directives (used to define the structure of an assembly and its types), attributes (which further qualify a given directive), and opcodes (which are used to implementation type members). You were introduced to the CIL compiler (ilasm.exe) and learned how to alter the contents of a .NET assembly with new CIL code and also the basic process of building a .NET assembly using raw CIL.

The latter half of this chapter introduced you to the System. Reflection. Emit namespace. Using these types, you are able to emit a .NET assembly on the fly to memory. As well, if you so choose, you may persist this in-memory image to a physical file. Recall that many types of System. Reflection. Emit will automatically generate the correct CIL directives and attributes using friendly types such as ConstructorBuilder, TypeBuilder, and so forth. The ILGenerator type can be used to inject the necessary CIL opcodes into a given member. While we do have a number of helper types that attempt to make the process of programming with the CIL opcode set more palatable, you must have an understanding of CIL when programming with dynamic assemblies.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 44.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Andrew Troelsen

About this chapter

Cite this chapter

(2005). Understanding CIL and the Role of Dynamic Assemblies. In: Pro C# 2005 and the .NET 2.0 Platform. Apress. https://doi.org/10.1007/978-1-4302-0060-4_15

Download citation

Publish with us

Policies and ethics