Closed sanjeev-saxena-us closed 6 months ago
This sounds like a Framework assembly trying to be used on Core.
The jar files I mentioned are an outside vendor's which is being used in one of our legacy Java apps. We need to use external vendor's jar files in our new .net8/C# app.
We did two options:
Here is a link to someone else's experience on this from last year: https://github.com/KevM/tikaondotnet/issues/156 Are you saying that IKVM is using .net framework?
Thoughts?
We ran the IKVMC utility to create a single .net dll from these jar file which worked. We referenced the created dll in the .net8 project and compiled which also worked. Then we new upped a few classes in the dll which also worked. However when we tried to new up a different class, we got the exception
You ran the wrong version of the tool, likely. You ran the Framework version, against the Framework libraries, and created a Framework assembly.
Please use IkvmReference.
Yes, that was the option 2 in my comment earlier.
<ItemGroup>
<PackageReference Include="IKVM" Version="8.8.0" />
</ItemGroup>
<ItemGroup>
<IkvmReference Include="some1.jar">
<AssemblyName>some1</AssemblyName>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<AssemblyFileVersion>1.0.0.1</AssemblyFileVersion>
</IkvmReference>
<IkvmReference Include="some2.jar">
<AssemblyName>some2</AssemblyName>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<AssemblyFileVersion>1.0.0.1</AssemblyFileVersion>
</IkvmReference>
<IkvmReference Include="some3.jar">
<AssemblyName>some3</AssemblyName>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<AssemblyFileVersion>1.0.0.1</AssemblyFileVersion>
</IkvmReference>
<IkvmReference Include="some4.jar">
<AssemblyName>some4</AssemblyName>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<AssemblyFileVersion>1.0.0.1</AssemblyFileVersion>
</IkvmReference>
</ItemGroup>
The class in the some2.jar that threw the exception was missing
During build, what errors or warning were output?
If you cannot reproduce it, you can check the .log file left behind in %TEMP%\ikvm\cache\1
There are no build errors. Also I do not see a ikvm folder in the %TEMP% folder
I'm going to bet there is and there were.
Likely, yes; its just that the Visual Studio 2022 build completes successfully (the output window reflects no errors). Where else can the ikvm folder be created?
%TEMP% is pretty much the only place it should be unless you managed to figure out how to override it with IkvmCacheDir in your project file.
It's where the built DLL files go.
Found the cache folder (for some reason it was hidden) - thanks for pointing me in this direction! You were right in that the error were in the log file (VS build actually succeeded without errors). I'll look at the IKVM generated log files to determine where the issue(s) are and report back.
The errors/warnings are emitted on the first build. But since IkvmReference caches the result, you only see them the first time.
To delete the cache and generate from the latest, do I simply delete the "ikvm" folder or the "cache" folder?
It always generates a new assembly if material changes were made. But, you can delete the folder to force it.
Sorry for the delay in responding; its working just fine.
Hi
I am working on a .net 8 Kubernetes service that needs to use a collection of jar files. Most of the Java classes get converted but when I try to new up a specific class in the jar file, I get the "Could not load type 'System.Reflection.Emit.MethodToken' from assembly mscorlib" exception. I realize that this class is in the .net framework which is blocking us from moving forward since the service will be hosted in a linux container in Azure Kubernetes. Is there a fix for this or a workaround?
Thanks