Skip to content

Fails on 32-bit with unclear error message #151

Open

Description

@mgravell

On .NET Framework, the default target architecture (unless specified explicitly) is "any", IIRC - and will default to x86; the package doesn't have x86 binaries (only x64), so on 32-bit it fails with Unable to load DLL 'duckdb'

Maybe add a 64-bit check, and/or explicitly specify the target architecture?


original report:

I see that there's a netstandard2.0 package in the nuget, but: it doesn't seem to work; it doesn't work in the tests here, and doesn't work in standalone packages either.

If it isn't expected to work on netfx, it might be worth simply dropping the netstandard2.0 target - but this might just be a packaging snafu

test setup example:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net472</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <LangVersion>12</LangVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="DuckDB.NET.Data.Full" Version="0.9.0.3"/>
    </ItemGroup>
</Project>

with:

using DuckDB.NET.Data;

using var conn = new DuckDBConnection("Data Source=:memory:");
conn.Open();

gives:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'duckdb': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at DuckDB.NET.NativeMethods.Startup.DuckDBOpen(String path, DuckDBDatabase& database, DuckDBConfig config, IntPtr& error)
   at DuckDB.NET.Data.Internal.ConnectionManager.GetConnectionReference(DuckDBConnectionString connectionString)
   at DuckDB.NET.Data.DuckDBConnection.Open()
   at Program.<Main>$(String[] args) in C:\Code\ConsoleApp7\ConsoleApp7\Program.cs:line 4

Activity

  1. changed the title [-]Packaging fails on .NET framwork despite netstandard target[/-] [+]Packaging fails on .NET framework despite netstandard target[/+] on Oct 11, 2023
  2. mgravell commented on Oct 11, 2023

    @mgravell
    Author

    ah, I understand - editing hugely...

  3. changed the title [-]Packaging fails on .NET framework despite netstandard target[/-] [+]Fails on 32-bit with unclear error message[/+] on Oct 11, 2023
  4. Giorgi commented on Oct 11, 2023

    @Giorgi
    Owner

    When PlatformTarget is AnyCpu or x86 the process is still 64-bit but duckdb.dll doesn't get copied to the output folder so I think adding a Environment.Is64BitProcess won't help at runtime.

    image

  5. mgravell commented on Oct 11, 2023

    @mgravell
    Author

    Suggestion: if the library has <PlatformTarget>x64</PlatformTarget>, it can't be referenced from an incompatible project - it gives an error message about the mismatch (although that might have problems for linux ARM)

  6. Giorgi commented on Oct 11, 2023

    @Giorgi
    Owner

    Ah I didn't know that. For Linux Arm, there is only a 64bit native binary so will it be a problem?

  7. mgravell commented on Oct 11, 2023

    @mgravell
    Author

    I don't know, honestly

  8. zhui19871 commented on Sep 19, 2024

    @zhui19871

    current, i am also meet this problem, how to fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions