This code demonstrates C# Reflection capabilities, showing how to dynamically load assemblies, inspect types, and invoke methods at runtime. It contains two main sections: basic reflection for type inspection and advanced reflection for dynamic method invocation.
Reflection is a powerful .NET feature that allows programs to:
Key Namespace: System.Reflection
string assemblyPath = "D:\\\\KaradDotNetDemos\\\\Demo\\\\MathLib\\\\bin\\\\Debug\\\\net8.0\\\\MathLib.dll";
Assembly assembly = Assembly.LoadFrom(assemblyPath);
Detailed Analysis:
assemblyPath
: Hard-coded path to external DLL fileAssembly.LoadFrom()
: Loads assembly from file systemAssembly.LoadFile()
: Loads from exact pathAssembly.Load()
: Loads from GAC or application directoryAssembly.GetExecutingAssembly()
: Gets current assemblySecurity Considerations: