sergey-tihon / Stanford.NLP.NET

Stanford NLP for .NET
http://sergey-tihon.github.io/Stanford.NLP.NET/
MIT License
595 stars 123 forks source link

System.TypeLoadException: Could not load type 'ikvm.internal.ClassLiteral` #131

Closed hbcondo closed 8 months ago

hbcondo commented 8 months ago

Hi, I've been successfully Splitting sentences in C# using Stanford.NLP with Windows 10 / C# / .NET 4.8 / Azure. I now have a need to develop this on a MacOS (Apple Silicon) / C# / .NET 8.0 and host as an Azure Function (Serverless). The project builds successfully and the function runs but I keep keep getting the below exception thrown during invocation:

System.TypeInitializationException: The type initializer for 'edu.stanford.nlp.pipeline.StanfordCoreNLP' threw an exception ---> System.TypeLoadException: Could not load type 'ikvm.internal.ClassLiteral from assembly 'IKVM.Java, Version=8.7.3.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58'

Both the .NET 4.8 and .NET 8.0 projects use their respective v4.5.0 NuGet packages which have a dependency on IKVM = 8.2.1 This is the version I use in the .NET 4.8 project but for the .NET 8.0 project, it uses the latest version of IKVM = 8.7.3.0 I tried installing IKVM = 8.2.1 in the .NET 8.0 project but then I get a lot of errors and can't compile.

Any ideas on how to get Stanford.NLP to work with .NET 8.0 and the latest version of IKVM?

sergey-tihon commented 8 months ago

Why MavenReference

    <ItemGroup>
        <PackageReference Include="IKVM" Version="8.7.3"/>
        <PackageReference Include="IKVM.Maven.Sdk" Version="1.6.3" PrivateAssets="all"/>
    </ItemGroup>
    <ItemGroup>
        <MavenReference Include="edu.stanford.nlp:stanford-corenlp" Version="4.5.5"/>
    </ItemGroup> 
hbcondo commented 8 months ago

Thank you for your quick reply @sergey-tihon MavenReference doesn't throw the exception