# Friday, 09 May 2003
« DotGNU & New Snapshot | Main | Eclipse on Mono »
Class.forName()

Stuart asks:

Can IKVMC handle Class.forName if the target class is in an assembly that isn't directly referenced by the assembly making the call?

Yes, but then you have to specify the assembly qualified name of the class. For example:

Class.forName("System.Windows.Forms.Form, " +
    "System.Windows.Forms, " +
    "Version=1.0.3300.0, " +
    "Culture=neutral, " +
    "PublicKeyToken=b77a5c561934e089");

Another alternative, when the class hasn't been compiled to an assembly, is to instantiate a class loader and use that to load the class:

URL[] classpath = new URL[1];
classpath[0] = new URL("...");
ClassLoader loader = new URLClassLoader(classpath);
Class clazz = loader.loadClass("...");

Currently, when ikvm.exe isn't used to start your application you don't have an application class loader that loads classes from the directories specified in the CLASSPATH environment variable.

Friday, 09 May 2003 11:16:56 (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]