最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How to Properly Reference a DLL Generated by IKVM in a .NET MAUI App? - Stack Overflow

programmeradmin3浏览0评论

I am working on a .NET MAUI application (multi-platform), and I need to use FTDI's D2XX library for USB communication on Android. Since the official FTDI SDK for Android is in Java (d2xx.jar), I am using IKVM to convert the .jar file into a .NET assembly (D2XX.dll).

What I Have Done So Far:

  1. Installed IKVM via NuGet (IKVM package).
  2. Added IkvmReference to my .csproj so that d2xx.jar is automatically converted to D2XX.dll at build time:
<ItemGroup>
    <IkvmReference Include="Platforms/Android/libs/d2xx.jar">
        <AssemblyName>D2XX</AssemblyName>
        <AssemblyVersion>1.0.0.0</AssemblyVersion>
        <Debug>portable</Debug>
    </IkvmReference>
</ItemGroup>
  1. Verified that D2XX.dll is correctly generated in bin/Debug/net8.0-android/.
  2. Manually copied D2XX.dll to Platforms/Android/libs/.
  3. Attempted to add it as a reference in my .csproj:
<ItemGroup>
    <Reference Include="D2XX">
        <HintPath>bin/Debug/net8.0-android/D2XX.dll</HintPath>
        <Private>true</Private>
    </Reference>
</ItemGroup>

Issue:

Even though D2XX.dll is generated and appears valid when opened in a decompiler (dnSpy/ILSpy), I cannot use it in my C# code (using D2XX; does not work).

Additionally, when I try to manually add D2XX.dll as a reference via Visual Studio Reference Manager, I get the error:

Questions:

  1. How do I properly reference D2XX.dll in a .NET MAUI project so that using D2XX; works?
  2. Should I be placing D2XX.dll in a different directory (bin/ vs. Platforms/Android/libs/)?
  3. Does MAUI require a specific way to reference IKVM-generated assemblies?

Any guidance or best practices for integrating IKVM with .NET MAUI would be greatly appreciated!

I am working on a .NET MAUI application (multi-platform), and I need to use FTDI's D2XX library for USB communication on Android. Since the official FTDI SDK for Android is in Java (d2xx.jar), I am using IKVM to convert the .jar file into a .NET assembly (D2XX.dll).

What I Have Done So Far:

  1. Installed IKVM via NuGet (IKVM package).
  2. Added IkvmReference to my .csproj so that d2xx.jar is automatically converted to D2XX.dll at build time:
<ItemGroup>
    <IkvmReference Include="Platforms/Android/libs/d2xx.jar">
        <AssemblyName>D2XX</AssemblyName>
        <AssemblyVersion>1.0.0.0</AssemblyVersion>
        <Debug>portable</Debug>
    </IkvmReference>
</ItemGroup>
  1. Verified that D2XX.dll is correctly generated in bin/Debug/net8.0-android/.
  2. Manually copied D2XX.dll to Platforms/Android/libs/.
  3. Attempted to add it as a reference in my .csproj:
<ItemGroup>
    <Reference Include="D2XX">
        <HintPath>bin/Debug/net8.0-android/D2XX.dll</HintPath>
        <Private>true</Private>
    </Reference>
</ItemGroup>

Issue:

Even though D2XX.dll is generated and appears valid when opened in a decompiler (dnSpy/ILSpy), I cannot use it in my C# code (using D2XX; does not work).

Additionally, when I try to manually add D2XX.dll as a reference via Visual Studio Reference Manager, I get the error:

Questions:

  1. How do I properly reference D2XX.dll in a .NET MAUI project so that using D2XX; works?
  2. Should I be placing D2XX.dll in a different directory (bin/ vs. Platforms/Android/libs/)?
  3. Does MAUI require a specific way to reference IKVM-generated assemblies?

Any guidance or best practices for integrating IKVM with .NET MAUI would be greatly appreciated!

Share Improve this question asked Mar 17 at 5:10 m4verickm4verick 892 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There is a near zero percent chance that a Java library intended for usage on Android specifically is going to work with IKVM in the first place. There is also a zero percent chance that IKVM at runtime will work on Android, as we don't even have Android runtime support.

发布评论

评论列表(0)

  1. 暂无评论