I'm using IKVM.NET in order to convert a Java library (signally, Strata) into a .NET library. Here are the steps I perform:
- I download the latest Strata release.
- I unzip all the
JARfiles contained into thelibfolder of the archive toC:\Strata\, including the following auxiliary libraries:- commons-math3-3.6.1.jar
- guava-26.0-jre.jar
- joda-beans-2.4.0.jar
- joda-convert-2.2.0.jar
- slf4j-api-1.7.25.jar
- I generate a keyfile for the library I want to create using the command
sn -k "C:\Strata\Strata.snk". - Using the binary bytecode compiler of
IKVM.NET, I convert theJARfiles ofStratainto a.NETlibrary with the following command:ikvmc -out:"C:\Strata\Strata.dll" -keyfile:"C:\Strata\Strata.snk" -assembly:Strata -version:2.2.0 -fileversion:2.2.0 -target:library -platform:anycpu -recurse:"C:\Strata\*.jar".
Once the process described above is done, even if a few warnings concerning missing classes are shown, I obtain a working .NET wrapper of Strata. If I create a new Visual Studio project referencing the Strata.dll assembly, I'm capable of using its classes and methods without problems.
What I would really love to achieve is to make the wrapper work in Excel VBA macros, so that I can instantiate and use Strata classes in the subs, according to the contents of the sheets.
This is what I tried so far, but to no avail:
- I register all the
IKVM.NETlibraries and theStratawrapper into theGACas follows:gacutil /i "C:\IKVM\IKVM.*.dll",gacutil /i "C:\Strata\Strata.dll". - I register the
Stratawrapper asCOMcomponent and I create its types library as follows:regasm /codebase /tlb "C:\Strata\Strata.dll".
Now, when I open Excel and I go under Development > Visual Basic > Tools > References... I can see the TLB file of Strata (located at "C:\Strata\Strata.tlb") and I can add it to the current project. But as soon as I type something the window or I open the Objects Browser, Excel crashes without providing any meaningful information about what's going on.
I'm totally clueless about this issue.
Is my registration process correct? Do I have to register the IKVM.NET libraries too and create their type libraries? Should I include them into the Excel VBA project together with the Strata wrapper type libraries? Could the problem be caused by the fact that I'm using a x64 version of Excel and the wrapper has been compiled under AnyCPU? Do I need to edit the wrapper by adding a ComVisible attribute on every public class? May this problem be due to the fact that the wrapper contains weird method names like ā\_Build01_\pā?