Open google-mirror opened 3 months ago
Haven't tried it since Core 3. Seems broken. Need to research changes made to single file.
Core 3 extracted files before running them, which is why this used to work.
Since .NET 5 AppContext.BaseDirectory
always returns actual .exe's directory in regular, single file and AOT scenarios. So I think it's safe to change home path detection to use this property instead, but we may introduce a behaviour change where ikvm would start always looking into exe's directory and not where the IKVM dll is located by itself. Maybe the better solution would be checking if Assembly.Location
is null or empty, then fall back to AppContext.BaseDirectory
.
This is happening to me on latest stable nuget (8.4.6 I think?). (Edit: 8.7.6) Adding the full error here for anyone searching on Google:
System.TypeInitializationException: The type initializer for 'java.lang.System' threw an exception.
---> System.TypeInitializationException: the type initializer for '<Module>' threw an exception.
---> System.TypeInitializationException: the type initializer for 'Internal' threw an exception.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at IKVM.Runtime.JVM.Properties.GetHomePath()
<etc>
I would suggest a check to see if the rootPath variable in GetHomePath is null or empty. If so, fall back to AppContext.BaseDirectory.
This should be resolved on 8.9 when it is released, as the changes were made to develop.
Throw Exception when SelfContained=true && PublishSingleFile=true since 'typeof(JVM).Assembly.Location' will get null
https://github.com/ikvmnet/ikvm/blob/1404d8467c509fe6074ac0e7a030323028b7706c/src/IKVM.Runtime/JVM.Properties.cs#L82
error IL3000: 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'