Web server iis - CHAPTER 15 UNDERSTANDING CIL AND THE ROLE
CHAPTER 15 UNDERSTANDING CIL AND THE ROLE OF DYNAMIC ASSEMBLIES 505 A dynamic assembly, on the other hand, is created in memory on the fly using the types provided by the System.Reflection.Emit namespace. The System.Reflection.Emit namespace makes it possible to create an assembly and its modules, type definitions, and CIL implementation logic at runtime. Once you have done so, you are then free to save your in-memory binary to disk. This, of course, results in a new static assembly. To be sure, the process of building a dynamic assembly using the System.Reflection.Emit namespace does require some level of understanding regarding the nature of CIL opcodes. Although creating dynamic assemblies is a fairly advanced (and uncommon) programming task, they can be useful under various circumstances: You are building a .NET programming tool that needs to generate assemblies on demand based on user input. You are building a program that needs to generate proxies to remote types on the fly based on the obtained metadata. You wish to load a static assembly and dynamically insert new types into the binary image. This being said, let s check out the types within System.Reflection.Emit. Exploring the System.Reflection.Emit Namespace Creating a dynamic assembly requires you to have some familiarity with CIL opcodes, but the types of the System.Reflection.Emit namespace hide the complexity of CIL as much as possible. For example, rather than directly specifying the necessary CIL directives and attributes to define a class type, you can simply make use of the TypeBuilder class. Likewise, if you wish to define a new instance-level constructor, you have no need to emit the specialname, rtspecialname, or .ctor tokens; rather, you can make use of the ConstructorBuilder. Table 15-8 documents the key members of the System. Reflection.Emit namespace. Table 15-8. Select Members of the System.Reflection.Emit Namespace Members Meaning in Life AssemblyBuilder Used to create an assembly (*.dll or *.exe) at runtime. *.exes must call the ModuleBuilder.SetEntryPoint() method to set the method that is the entry point to the module. If no entry point is specified, a *.dll will be generated. ModuleBuilder Used to define the set of modules within the current assembly. EnumBuilder Used to create a .NET enumeration type. TypeBuilder May be used to create classes, interfaces, structures, and delegates within a module at runtime. MethodBuilder Used to create type members (such as methods, local variables, EventBuilder properties, constructors, and attributes) at runtime. LocalBuilder PropertyBuilder FieldBuilder ConstructorBuilder CustomAttributeBuilder ParameterBuilder ILGenerator Emits CIL opcodes into a given type member. OpCodes Provides numerous fields that map to CIL opcodes. This type is used in conjunction with the various members of System.Reflection. Emit.ILGenerator.
Check Tomcat Web Hosting services for best quality webspace to host your web application.