Tuesday, January 15, 2008

.NET 2.0 plug-in for 1.1 application is nonsense

Quite evident right ? NET 1.1 application will load 1.1 CLR, which is unable to (dynamically) load 2.0 assembly of plug-in.

Actually I have spent many hours to figure it out. I was confused by too many degrees of freedom in area where my problem could be. I'm playing with IKVM to translate Robocode for .NET (I will post about it later). So I was fully focused on problems in Robocode, IKVM and Java, because all three things are new to me.

Now imagine following behavior:
1) You have some core application (robocode) and you are creating new plug-in (Winforms UI). When you start the core application and specify name of plug-in, it will fail to load it.
2) When you create wrapper/starter application to load core application and call main() on it, UI assembly will load and work. Weird?

I didn't noticed that IKVM 0.36 compiler generates .NET 1.1 core application from robocode.jar for me. This is explanation why first test failed. My .NET wrapper application was compiled for 2.0, so it loaded 2.0 CLR and it was able to load both 1.1 core application and 2.0 UI plugin.

I was unable to see it until Jeroen Frijters told me that I'm using 1.1 compiler. This is not a problem as ikvm 0.37 will be distributed as .NET 2.0 application. I was very happy that the solution was that simple, so it made my day today!