You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make a HelloWorld console app by using IKVM and Native AOT. The main method is written in C# and invokes a JDK method. However, when I run the app, it throws a System.TypeInitializationException.
Unhandled Exception: System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.ArgumentNullException.Throw(String) + 0x2b
at System.IO.Path.Combine(String, String) + 0x23
at IKVM.Runtime.JVM.Properties.GetHomePath() + 0x157
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode) + 0xb0
at System.Lazy`1.ExecutionAndPublication(LazyHelper, Boolean) + 0x77
at System.Lazy`1.CreateValue() + 0xc8
at IKVM.Runtime.JVM.Internal..cctor() + 0xc9
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xb9
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x14a
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0xd
at IKVM.Runtime.JVM.Init() + 0x1b4
at IKVM.Runtime.RuntimeInit.Init() + 0x66
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunInitializers(TypeManagerHandle, ReadyToRunSectionType) + 0x39
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunModuleInitializers() + 0x36
at IKVMDemoAppNativeAotLibrary!<BaseAddress>+0x575887
Warnings during AOT compilation:
warning IL3000: IKVMDemoAppNativeAotLibrary.Program
.GetHomePath(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a s
ingle-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. [C:\Pro
jects\IKVMDemoApp\IKVMDemoAppNativeAotLibrary\IKVMDemoAppNativeAotLibrary.csproj]
ILC : warning IL3000: IKVM.Runtime.JVM.Properties.GetIkvmProperties(): 'System.Reflection.Assembly.Location.get' always
returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, cons
ider calling 'System.AppContext.BaseDirectory'. [C:\Projects\IKVMDemoApp\IKVMDemoAppNativeAotLibrary\IKVMDemoAppNativeA
otLibrary.csproj]
ILC : warning IL3000: IKVM.Runtime.JVM.Properties.GetHomePath(): 'System.Reflection.Assembly.Location.get' always retur
ns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider c
alling 'System.AppContext.BaseDirectory'. [C:\Projects\IKVMDemoApp\IKVMDemoAppNativeAotLibrary\IKVMDemoAppNativeAotLibr
ary.csproj]
Dynamic linking has the same outcome as static linking.
Steps to reproduce
Create a C# console app that uses IKVM to call a JDK method. For example:
namespace IKVMDemoApp;using System = java.lang.System;publicclassConsoleApp{publicstaticvoidmain(String[]args){
System.@out.println("Hello, World!");}}
Create a C# class library that exports the main function. For example:
As neat as it would be for NAOT to work on IKVM, it is likely darn near impossible as it stands, and very low priority. I'll leave this open, since it's something to tackle some day..... But that's probably way down the road.
wasabii
changed the title
IKVM and Native AOT HelloWorld app throws System.TypeInitializationException
IKVM NativeAOT support
Feb 6, 2024
Description
I'm trying to make a HelloWorld console app by using IKVM and Native AOT. The main method is written in C# and invokes a JDK method. However, when I run the app, it throws a System.TypeInitializationException.
Warnings during AOT compilation:
Dynamic linking has the same outcome as static linking.
Steps to reproduce
The text was updated successfully, but these errors were encountered: