Closed ubythulla closed 8 months ago
Stack trace please.
Stack trace
at Main.Calculate.calculator(int a, int b) in C:\Users\Documents\Visual Studio 2019\Projects\Test\Program.cs:line 5
Exception messgae
Calculate.Addition.Sum(II)LCalculate.Addition;
Output window error message
Exception thrown: 'java.lang.NoSuchMethodError' in Main.dll
Ok. Chances are the body of the calculator method was replaced with NoSuchMethodException at compile time. The first time building you probably had warning messages about missing classes or missing methods.
You can find those previous log files along side the assemblies which were generated in the IKVM cache directory. Which will be in your temp directory/ikvm
This is sample code only, but I can see that several classes are missing in the original code. Would the NoSuchMethodException be resolved if I fixed the class missing errors?
Likely, yes.
When using static compilation (which is what you're using, converting a JAR to a DLL), IKVM has to be able to resolve all the types that would otherwise be needed at runtime in Java, since those types have to be baked into assemblies at that point in time. If it can't resolve one, it tries to gracefully fall back, generating what it can, and generating code that throws NoSuchMethod just like Java would do at runtime.
Ok. I appreciate you very much helping me understand this. I will try to fix the missing class errors.
Closing. User can reopen if a bug still exists. It sounds like he was just building things in the wrong order.
I am still having this issue
I added the jars directly to the dot net project and added ikvm reference in the csproj file as like below
<ItemGroup>
<IkvmReference Include="Main.jar">
<AssemblyName>Main</AssemblyName>
<AssemblyVersion>2.5</AssemblyVersion>
<AssemblyFileVersion>2.5.0.0</AssemblyFileVersion>
</IkvmReference>
</ItemGroup>
I can able to access the java method which comes from the Main.jar in the C# without any error as like below
common.net.util.ConvertUtils.convertFromEntityList(rules, seqState);
During the run time of application I am getting the error and the cache file also contains the same error.
ERROR: warning IKVMC0117: Emitted java.lang.NoSuchMethodError in "common.net.util.ConvertUtils.convertFromEntityList(Ljava.util.List;Lcommon.net.util.ConvertUtils$SequenceState;)Ljava.util.List;"
Below are the sample java code
another class from another package
And, I reference this from a C# console application:
throws error as
IKVM tried to find the static Sum method from Main dll instead of Calculate dll.
In the console app, I inserted a classloader as seen below, but that did not fix the problem. Same error only thrown
I added the jars directly to the dot net project and added ikvm reference in the csproj file as like below
Your help will be much appreciated, we are stuck here and not able to proceed further. Thanks in advance.