ClassLoader

The ClassLoader attempts to instantiate a dynamic instance of a class by resolving the existence of the class in either currently loaded assemblies or inferred assemblies found in the local path.

The ClassLoader is a static class and keeps no state between, during, or after a method call.

Methods

public static object GetInstance(string typeName)
Gets a dynamic instance of a class. Returns a dynamic instance of a class or null if no class can be found.
  • typeName - The qualified type name to instantiate.
This method calls: GetInstance(typeName, null, false)

public static object GetInstance(string typeName, string assemblyFileName, bool testExternalAssemblies)
Gets a dynamic instance of a class. Returns a dynamic instance of a class or null if no class can be found.
  • typeName - The qualified type name to instantiate.
  • assemblyFileName - An external assembly to test if testExternalAssemblies is true
  • testExternalAssemblies - A flag to look at external assemblies.
This method has predefined rules for how it attempts to ascertain the location of a class. First it looks through the current calling assembly. Next it attempts to find the class in the assembly with the same name as typeName or assemblyFileName if testExternalAssemblies is true. The assembly it attempts to load is first looked for in the executing assembly's location (this generally works for client applications) and then it looks in the Assembly's code base location (this generally works for web applications). Failing all of the above it will return null as either no assembly or class could be found.

public static object GetInstance(string typeName, Assembly assembly)
Gets a dynamic instance of a class. Returns a dynamic instance of a class or null if no class can be found.
  • typeName - The qualified type name to instantiate.
  • assembly - The assembly containing the type.

Last edited Mar 19, 2013 at 4:50 PM by jsaundea, version 5

Comments

No comments yet.