|
Reflection provides objects (of type Type Class) that encapsulate assemblies, modules and types. You can use
reflection to dynamically create an instance of a type, bind the type to an
existing object, or get the type from an existing object and invoke its methods
or access its fields and properties. If you are using attributes in your code,
Reflection enables you to access them.CLR is an internal reflection that checks
the framework version.
Through reflection
1.
I can load assembly dynamically.
2.
I can open, browse the assembly.
3.
Reflection gets the info like version of
assembly. Using manifest we can go for browsing assembly.
4.
Access all info of class to base class.
5.
Without using header file we can call dll
function by reflection (let binding).
6.
Through reflection we can add info in a class.
7.
Through reflection we can achieve late binding.
Example:
How to brows DLL with the help of Reflection?
Step 1: Type below code on
notepad and save with info.cs in
drive D

Step 2:
Open
Visual studio prompt and make DLL of
info.cs file

Step 3: Type
below code on notepad and save
with showinfo.cs in drive
D

Step 4:
Open
Visual studio prompt and compile the
showinfo.cs file

Step 5:
Execute showinfo.cs file

Step 6: we can
browse info.dll file via ildasm and check class, function name

|