Runtime Binding: Class.forName Semantics
Classes loaded using the Class.forName API are dynamically bound to the application at run time.
The Class.forName(String className) method does not use the CLASSPATH environment variable to locate classes. Instead, a search for classes is conducted in the following locations, in order:
The calling assembly
All assemblies currently loaded into the current application's AppDomain
Assemblies specified in the <CODEBASE> tag of the application configuration (.config) file
The ApplicationBase of the application
All managed DLLs found in the directories specified by the <PROBING> tag of the application configuration file
The search terminates if the class is found at a particular step. If no configuration file is found, or if errors are encountered in parsing the configuration file, steps 3 and 5 are skipped. If the class is not found in any of the steps, ClassNotFoundException is thrown.
Visual J# also provides an additional method in the class java.lang.Class for locating and loading classes from an assembly, as follows:
Class.forName(String assemblyName, String className, boolean absolutePath)
This method searches for the class specified by the className parameter in the assembly specified by the assemblyName parameter. The assemblyName parameter should specify the display name of the assembly (see AssemblyName Class for more information). If the Boolean parameter absolutePath is True, then assemblyName represents an absolute path that specifies the location of the assembly. If absolutePath is False, then it is assumed that no path has been specified and the common language runtime assembly search heuristics are used to locate and load the assembly. If the class is not found in the specified assembly or the specified assembly could not be found, ClassNotFoundException is thrown.