Late Binding : Assembly Load « Assembly « C# / CSharp Tutorial






using System;
using System.Reflection;
using System.IO;

public class MainClass
{
  public static int Main(string[] args)
  {
    Assembly a = null;
    try
    {
      a = Assembly.Load("YourLibraryName");
    }
    catch(FileNotFoundException e)
    {Console.WriteLine(e.Message);}
  
    Type classType = a.GetType("YourLibraryName.ClassName");

    object obj = Activator.CreateInstance(classType);
  
    MethodInfo mi = classType.GetMethod("MethodName");

    mi.Invoke(obj, null);

    object[] paramArray = new object[2];    
    paramArray[0] = "Fred";
    paramArray[1] = 4;
    mi = classType.GetMethod("MethodName2");
    mi.Invoke(obj, paramArray);

    return 0;
  }
}








12.4.Assembly Load
12.4.1.Assemblies
12.4.2.difference between Assembly.Load and Assembly.LoadFrom
12.4.3.Load types(classes) from a Assembly(exe file)
12.4.4.Load the System.Xml assembly using an AssemblyName
12.4.5.Create Type by Assembly qualifed type name
12.4.6.Late Binding
12.4.7.Assembly unloading
12.4.8.Dynamic assembly introspection
12.4.9.Deeper Reflection: Listing All the Types in an Assembly
12.4.10.Assembly Loader
12.4.11.GetManifestResourceStream