I'm trying to create a .NET DLL out of a .jar using ikvmc and I want it to have certain assembly attributes. There is an -assemblyattributes
option for ikvmc and I'm using it, but the assembly attributes don't appear in the assembly.
Here's what I'm doing.
I have a Hello.java file:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}
I compile it like this: javac Hello.java
I turn it into a jar: jar cvf hello.jar Hello.class
I generate the core library stub jar: ikvmstub mscorlib
I have an AssemblyInfo.java file:
@cli.System.Reflection.AssemblyTitleAttribute.Annotation("My Assembly Title")
@cli.System.Reflection.AssemblyProductAttribute.Annotation("My Assembly Product")
@cli.System.Reflection.AssemblyCompanyAttribute.Annotation("My Assembly Company")
@cli.System.Security.AllowPartiallyTrustedCallersAttribute.Annotation
interface AssemblyInfo {}
I compile it like this: javac -cp mscorlib.jar AssemblyInfo.java
Then I run ikvmc to generate my DLL: ikvmc -target:library -assemblyattributes:AssemblyInfo.class hello.jar
This generated hello.dll, which I then examine using ildasm and the specified attributes are not present.
The IKVM version is 8.0.5449.1.
Can anyone help me find out what I did wrong?
Okay, since nobody stepped up to answer this, I downloaded IKVM source code and went to town with a debugger.
It turns out that IKVM will quietly ignore any annotation for which it can't find a class, without reporting an error or a warning. The reason why it couldn't find these annotations is that they are defined in mscorlib.dll, which you have to explicitly include in references on the command line.
The correct command to to successfully apply annotations in the example I gave would be:
ikvmc -target:library -assemblyattributes:AssemblyInfo.class -r:mscorlib.dll hello.jar