Chapter 6. Reflection


Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Part II.  Advanced Object-Oriented Programming

In This Chapter

  • Reflection Namespace

  • Emitting Types at Runtime Using Reflection

  • Other Places Reflection Is Used>

  • Localization

  • Summary

An assembly is an application plus its self-describing information. The inclusion of self-describing information, or metadata, was designed to resolve the problem of "DLL Hell." "DLL Hell" is the moniker ascribed to the current versioning problems related to registering applications in the registry. Assemblies contain information about an application in addition to the Intermediate Language (IL) code that is considered to be the application. Reflection is the capability to dynamically discover and use information in assemblies.

Reflection allows developers to discover information about an assembly and dynamically create types and invoke capabilities on those types at runtime. Additionally, reflection allows developers to dynamically define new types at runtime.

The capability to discover information about types at runtime is not completely new. COM provided the QueryInterface method, which enabled developers to determine whether an object supported a specific interface. Reflection is an evolution of this capability on a larger scale. The System.Reflection namespace allows developers to discover information about assemblies, files, modules, methods , types, and much more. Additionally, reflection supports dynamic localization of codethe ability to modify code for a specific locale, also referred to as internationalizationplus the capability to emit code dynamically, and it directly addresses certain security issues raised by such dynamic activity.

Chapter 6 provides an overview of the System.Reflection namespace and explores some specific aspects of reflection in the Common Language Runtime (CLR).


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
Year: 2001
Pages: 222 © 2008-2017.
If you may any questions please contact us: