简体   繁体   中英

IKVM - Using a generated Assembly (from a JAR) causes a MissingMethodException in Type Initializer

We are having an issue with a .NET dll that was converted from a jar file using ikvmc. When trying to instantiate "My", we see the error below (this is the output of the extension method "printStackTrace" located in "ikvm.extensions", since this seems to be what people knowing about IKVM are looking for).

The "App" class in the Java code inherits from Hashtable. Also, when we use ikvmc to generate an executable (rather than a dll) from the same jar file (this time with the Main method set in the manifest file) and we run that exe file, everything works fine. "My" gets instantiated in the Main method of the java code and all works ok.

java.lang.ExceptionInInitializerError
    at App.<init>(App.java)
    at My.<init>(My.java:107)
    at cli.Tests.Program.Main(Program.cs:58)
    at cli.System.AppDomain._nExecuteAssembly(Unknown Source)
    at cli.System.AppDomain.ExecuteAssembly(Unknown Source)
    at cli.Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly(Unknown Source) Caused by: cli.System.MissingMethodException: Method not found: 'Void java.util.Hashtable.__<clinit>()'.
    at cli.Tests.Program.Main(Program.cs:65)
    ... 3 more

Any ideas what we can do differently to get around this? In case you are wondering, we included IKVM via Nuget, so the 28 IKVM assemblies are included, yes.

I was able to resolve the issue. As explained here ( MissingMethodException using IKVM ), the ikvmc version must match the assembly versions you are using in the .NET project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM