Define Reflection in C#?

Started by VelMurugan, Jan 27, 2009, 04:47 PM

Previous topic - Next topic

VelMurugan

Define Reflection in C#?

Reflection is the mechanism provided by the .NET Framework to allow you to inspect how a program is constructed.

Using reflection, you can obtain information such as the name of an assembly and what other assemblies a given assembly imports.

You can even dynamically call methods on a type in a given assembly.

Reflection also allows you to create code dynamically and compile it to an in-memory assembly or to build a symbol table of type entries in an assembly.

Reflection is a very powerful feature of the Framework and, as such, is guarded by the runtime.

The ReflectionPermission must be granted to assemblies that are going to access the protected or private members of a type.

If you are going to access only the public members of a public type, you will not need to be granted the ReflectionPermission.

Code Access Security has only two permission sets that give all reflection access by default: FullTrust and Everything.

The LocalIntranet permission set allows for the ReflectionEmit privilege that allows for emitting metadata and creating assemblies or the MemberAccess privilege for performing dynamic invocation of methods on types in assemblies.

Source : csharpthegreat