# Friday, 09 May 2003
« DotGNU & New Snapshot | Main | Eclipse on Mono »

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, " +

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]
Friday, 09 May 2003 17:13:04 (W. Europe Daylight Time, UTC+02:00)
Hmm. Are any parts of that optional? I can imagine asking users to specify "org.postgres.Driver, pgjdbc" as their driver, but "org.postgres.Driver, pgjdbc, Version=1.0, Culture=neutral, PublicKeyToken=blahblahblah" is probably a little extreme. Especially since if they were going to compile the JDBC driver themselves, they'd need to IKVMC it, sign it, and then figure out the public key token.

Is there any way to at least support forName without the Version, Culture and PublicKeyToken parts?
Friday, 09 May 2003 17:59:56 (W. Europe Daylight Time, UTC+02:00)
If the assembly is not signed, you only have to specify the type name and the assembly name (just like you imagined :-))
Home page

I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.

Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)

Comment (HTML not allowed)  

Live Comment Preview