Introduction to .NET Reflection
Programming languages like C++ had the ability to collect information on the types. But this ability had limited scope. With .NET there is a powerful mechanism called .NET Reflection that not only allows you to introspect types but also raise methods on those types during runtime. Though the process of retrieving types information in .NET Reflection is slow compared to direct access of a method, property, or field, .NET Reflection provides dynamic execution of code and controls when used sparingly. All types with their methods are stored in assemblies.
Assemblies are the most integral part of any .NET application. All the functionality of .NET application can be exposed through assemblies. The .NET Reflection provides you with Application Programming Interface (APIs) to inspect assemblies. Apart from inspecting assemblies, reflection APIs also allows you to dynamically create assembly in memory and use it in your program code. All the APIs related to .NET Reflection are located under System.Reflection namespace. These .NET Reflection APIs are also used to develop applications editors, class browsers, and add-ons for Integrated Development Environment (IDEs).
Since .NET most often uses types, .NET Reflection is frequently required when you do not know the particular type that you are dealing with at compile time. For example, if you dynamically create server-side controls or objects at runtime, or use meta-based programming where some of the data is dynamically created based on data stored in a database, you often create things in hurry. This is where the .NET Reflection comes to rescue when it can be used against these dynamic runtime generated objects which the compiler knows nothing about.
other usages for .NET Reflection like compilers for languages such as
JScript make use of reflection to construct symbol tables and the classes
in the System.Runtime.Serialization namespace makes use of reflection
to access data and to determine which fields to persist. Moreover, fhe
classes in the System.Runtime.Remoting namespace also use reflection through
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage