ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.22k stars 111 forks source link

Could not locate ikvm.home when establishing VFS. #358

Closed podlodkin closed 1 year ago

podlodkin commented 1 year ago

File: IKVM.Runtime\JVM.Properties.cs

Function: GetHomePath

Code: var rootPath = Path.GetDirectoryName(typeof(JVM).Assembly.Location); returns “shadow-copying” directory path. For example, C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\c027dea8\2d30b62c\assembly\dl3\e775bdb1\00e9c755_4899d901

There is no “ikvm” catalogue and as the result we have an error:

Could not locate ikvm.home when establishing VFS.

Rather than calling typeof(JVM).Assembly.Location, you can call typeof(JVM).Assembly.CodeBase which gives you the original install directory (which contains ikvm folder).

P.s. This is not a constant error - it depends on environmental configuration (VS, IIS, ...).

AliveDevil commented 1 year ago

Only available/usable on .NET Framework (as in your case).

Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.

Assembly.CodeBase Property

Exceptions NotImplementedException .NET Core and .NET 5+ only: In all cases.

Exceptions

For .NET Core this won't work, at all.

podlodkin commented 1 year ago

For .NET Core this won't work, at al.

Maybe we need different rootPath algorithms for .net core and .net framework. Actual algorithm doesn't work for .net 4.8.

AliveDevil commented 1 year ago

Shadow-Copying is a nightmare, and may or may not work (experimentally) in .NET Core as well.

https://github.com/dotnet/aspnetcore/issues/47465

podlodkin commented 1 year ago

Maybe we can use (optionally) an environmental parameter (as IKVM_PATH).

wasabii commented 1 year ago

We'll just have it read out of ConfigurationManager at a higher priority. But yeah shadow copy is evil.