Re: Unable to Expose Java Methods to Excel VBA
Jeroen Frijters <[email protected]> Tue, 2 Jun 2015 07:46:19 +0000
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Have you tried following these steps: http://stackoverflow.com/questions/14967080/how-do-i-make-a-dll-created-with-ikvm-com-visible Second, why are you using ildasm/ilasm to strong name sign the assembly? You can use the ikvmc -keyfile:<keyfilename> option to directly sign the assembly. Regards, Jeroen From: Colin Chin [mailto:[email protected]] Sent: Tuesday, June 2, 2015 4:58 To: [email protected] Subject: [Ikvm-developers] Unable to Expose Java Methods to Excel VBA 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 ------------------------------------------------------------------------------ _______________________________________________ Ikvm-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ikvm-developers