System.Reflection namespace in C#


System.Reflection namespace in C# The System.Reflection namespace in C# contains the types that provide information about assemblies, modules, members, parameters, and other items in the code by examining the metadata. The Assembly class in this namespace represents an assembly. Typically, you can access it using the Assembly property on a Type.

An assembly's identity consists of four items −

  • Simple name
  • Version from the AssemblyVersion attribute in the major.minor.build.revision format (0.0.0.0 if absent)
  • Culture (neutral if not a satellite)
  • Public key token (null if not strongly named)

A fuller qualified assembly name is a string, and it includes these identifying items in the format −

simple-name, Version=version, Culture=culture, PublicKeyToken=public-key

For example,

Assembly assembly = typeof (Person).Assembly; // Person is a class name
// Prints: c-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Console.WriteLine(assembly.FullName);

Assembly Loading is the process of loading an assembly from a known location. Typically, the CLR can load the assembly using its full name. This process is called assembly resolution. Assembly resolution is performed when the CLR needs to resolve a dependency or you, as a programmer, want to load an assembly dynamically, using the Assembly.Load(assemblyName) method.

Updated on: 19-May-2021

393 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements