ikvmnet / ikvm

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

.net console application fell over when converting Stanford NLP libraries #535

Closed NeilWP closed 2 weeks ago

NeilWP commented 2 weeks ago

This error message appeared and I followed the request to open an issue for you...

IKVM.NET Compiler (8.2.1+Branch.main.Sha.e85684966cf595d7942d6930fda9c27d23b509e1) ERROR: Copyright © 2022 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug ERROR: ERROR: ERROR: *** INTERNAL COMPILER ERROR *** ERROR: ERROR: PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE ERROR: ERROR: ikvmc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 ERROR: C:\Users\nwpno\.nuget\packages\ikvm\8.2.1\bin\ikvmc\netcoreapp3.1\win7-x64\ ERROR: 3.1.27 64-bit ERROR: ERROR: System.IO.FileNotFoundException: netstandard ERROR: at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in D:\a\ikvm\ikvm\src\IKVM.Reflection\Universe.cs:line 789 ERROR: at IKVM.Internal.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList1 references, IList1 userLibPaths) in D:\a\ikvm\ikvm\src\ikvmc\IKVM\Internal\AssemblyResolver.cs:line 93 ERROR: at ikvmc.IkvmcCompiler.Compile(String[] args) in D:\a\ikvm\ikvm\src\ikvmc\IkvmcCompiler.cs:line 178 ERROR: at ikvmc.IkvmcCompiler.Main(String[] args) in D:\a\ikvm\ikvm\src\ikvmc\IkvmcCompiler.cs:line 112

ikvm and ikvm.reflector were added as project references via NUGET The following variables were defined .

// Path to the directory where the IKVM binaries are located
string ikvmPath = @"C:\Users\GE2024\.nuget\packages\ikvm\8.2.1\bin\ikvmc\netcoreapp3.1\win7-x64\";

// Path to the Stanford NLP JAR files
string jarDir = @"J:\00001 DATASCIENCE\WMOS_Politics\Politics\Stanford\stanford-corenlp-4.5.7";

// Output directory for the DLL files
string outputDir = @"J:\00001 DATASCIENCE\WMOS_Politics\Politics\Stanford\StanfordNET";

// Path to the .NET Standard library
string netStandardLibraryPath = @"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\netstandard.dll";

and consumed by

foreach (string jarFile in Directory.GetFiles(jarDir, "*.jar"))
 {
     string dllFileName = Path.GetFileNameWithoutExtension(jarFile) + ".dll";
     string dllFilePath = Path.Combine(outputDir, dllFileName);
     string ikvmcPath = Path.Combine(ikvmPath, "ikvmc.exe");
     string arguments = $"-target:library -out:\"{dllFilePath}\" \"{jarFile}\" -reference:\"{netStandardLibraryPath}\"";
     RunProcess(ikvmcPath, arguments);
 }

The value of arguments at run time is -target:library -out:"J:\00001 DATASCIENCE\WMOS_Politics\Politics\Stanford\StanfordNET\ejml-core-0.39-sources.dll" "J:\00001 DATASCIENCE\WMOS_Politics\Politics\Stanford\stanford-corenlp-4.5.7\ejml-core-0.39-sources.jar" -reference:"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\netstandard.dll"

and execution of the process is defined as

static void RunProcess(string fileName, string arguments)
{
    var processStartInfo = new ProcessStartInfo
    {
       FileName = fileName,
        Arguments = arguments,
        RedirectStandardOutput = true,
        RedirectStandardError = true,
        UseShellExecute = false,
        CreateNoWindow = true
    };
    using (var process = new Process())
    {
        process.StartInfo = processStartInfo;
        process.OutputDataReceived += (sender, e) => Console.WriteLine(e.Data);
        process.ErrorDataReceived += (sender, e) => Console.WriteLine($"ERROR: {e.Data}");
        process.Start();
        process.BeginOutputReadLine();
        process.BeginErrorReadLine();
        process.WaitForExit();
    }

All stanford files were unzipped and local to the console app.

wasabii commented 2 weeks ago

Pretty old IKVM version. I'm going to ask you to update first.

Second, what are you trying to do here? Execute ikvmc.exe from inside .NET? How come?

I also have no idea what ikvm.reflector is. Now why you would need to add IKVM as a project reference when you're executing a command line program not even in the IKVM package. I am in total, at a loss as to what you're trying to do here.

NeilWP commented 2 weeks ago

Hi JeromeInstalled the version from nuget ! So if it’s not up to date there ?? I was trying to get an implementation of. StanfordNLP going in  a windows service. Apparently I should be able to convert the NLP jars to DLLsMy regards NeilOn 15 Jun 2024, at 20:19, Jerome Haltom @.***> wrote: Pretty old IKVM version. I'm going to ask you to update first. Second, what are you trying to do here? Execute ikvmc.exe from inside .NET? How come?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

wasabii commented 2 weeks ago

Yes, but why are you writing code that executes ikvmc.exe? That's not anywhere close to how a normal users would use IKVM.

And it's printing out 8.2.1.

I have no idea what you're trying to do.

NeilWP commented 2 weeks ago

It’s what chat got and co pilot suggested See screenshot, it’s what co pilot suggested with some variation in coding but still referring to ikvm and malvern to convert jar to DLL. So if that is incorrect it must be the documentation exposed to those Llm.

I have found a solution of my own. So you can close the ticket. I have removed the packages having no use for them My regards Neil

On Sun, 16 Jun 2024 at 00:05, Jerome Haltom @.***> wrote:

Yes, but why are you writing code that executes ikvmc.exe? That's not anywhere close to how a normal users would use IKVM.

— Reply to this email directly, view it on GitHub https://github.com/ikvmnet/ikvm/issues/535#issuecomment-2170940299, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP2Q6OSUO54A5XRBKFTFL33ZHS3BNAVCNFSM6AAAAABJLNK3TCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZQHE2DAMRZHE . You are receiving this because you authored the thread.Message ID: @.***>

NightOwl888 commented 2 weeks ago

FYI - I have an example of how to consume Stanford CoreNLP using IKVM, if it helps: https://github.com/NightOwl888/lucenenet-opennlp-mavenreference-demo

wasabii commented 2 weeks ago

AI is stupid.