[Ikvm-developers] Unable to Expose Java Methods to Excel VBA
Brought to you by:
jfrijters
|
From: Colin C. <te...@gm...> - 2015-06-02 02:58:24
|
Hi,
I was trying to call Java methods from with Excel VBA.
I tried one of the sample, and here is my code:
Assembly.java
import cli.System.Runtime.InteropServices.*;
@cli.System.Runtime.InteropServices.ComVisibleAttribute.Annotation(true)
interface Iassembly {
public int method1(int x,int y);
}
@ClassInterfaceAttribute.Annotation(ClassInterfaceType.__Enum.AutoDual)
public class assembly implements Iassembly
{
public int method1(int x, int y)
{
return x + y;
}
}
And these are the steps I have followed to use IKVM to convert the java
class to DLL:
1. javac -cp mscorlib.jar;. assembly.java
2. ikvmc -out:assembly.dll assembly.class -r:mscorlib.dll
3. tlbexp assembly.dll
I then signed the DLL with a strong name by doing these:
1. ildasm /all /out=assembly.il assembly.dll
2. sn -k mykey.snk
3. ilasm /dll /key=mykey.snk assembly.il
Then, I do the type library export:
1. tlbexp assembly.dll
2. regasm /codebase assembly.dll /tlb
Everything runs well, and when I add reference in excel VBA, I can see
"assembly" is there. But when I use object browser to see the methods,
nothing is exposed, I only see the one <global> word there.
Can someone please tell me what have I done wrong in my java code? Anything
I need to add to expose my methods to be usable in excel VBA?
Many thanks.
Cheers,
Colin
|