CoreyKaylor / Lightning.NET

.NET library for LMDB key-value store
Other
397 stars 82 forks source link

lmdbautoresize.dll can't load on windows x86 #154

Closed pkindruk closed 1 year ago

pkindruk commented 1 year ago

Hi, I have been using x64 version for quite a while, which works. But recently I had to run my project on x86 and it fails with DllNotFoundException. After some debugging I found simple repro steps:

  1. Download win-x86 lmdbautoresize.dll from sources
  2. Run console app with this code:
    
    using System.Runtime.InteropServices;

const string path = @"c:\Users\admin\Downloads\lmdbautoresize.dll";

Console.WriteLine($"File exists={File.Exists(path)}"); NativeLibrary.Load(path); Console.WriteLine("Success");

The output is below. Result is the same when using `'C:\Program Files (x86)\dotnet\dotnet.exe' run` on Windows x64 machine.

PS C:\Users\admin\repos\test> dotnet run -c Debug File exists=True Unhandled exception. System.DllNotFoundException: Unable to load DLL 'c:\Users\admin\Downloads\lmdbautoresize.dll' or one of its dependencies: The specified module could not be found. (0x8007007E) at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError) at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath) at Program.

$(String[] args) in C:\Users\admin\repos\test\Program.cs:line 6

x86 VM environment info:

PS C:\Users\admin\repos\test> dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.404 Commit: be4f3ec411

Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win10-x86 Base Path: C:\Program Files\dotnet\sdk\6.0.404\

global.json file: Not found

Host: Version: 6.0.12 Architecture: x86 Commit: 02e45a41b7

.NET SDKs installed: 6.0.404 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET: https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info

AlgorithmsAreCool commented 1 year ago

This should work...? Must be a build / packaging issue. I'll try to replicate it

CoreyKaylor commented 1 year ago

I'm pretty sure this was tested, but can you try pulling the previous version of the x86 binary? I'm wondering if the flag wasn't properly set and didn't produce the 32 bit binary.

CoreyKaylor commented 1 year ago

Nevermind, I've verified that there is something off about the 32 bit dll.

I'm working on putting together a better script to keep the native libs up to date and less manual than it is today. Hopefully that will reduce the possibility of this happening again.

CoreyKaylor commented 1 year ago

https://github.com/CoreyKaylor/Lightning.NET/pull/157 Should fix your issue.

pkindruk commented 1 year ago

'lmdbautoresize.dll' is loading now in test app. Can't verify on real app yet, I have some issues with configuration on my side. It will take some time before I get there to resolve them.

CoreyKaylor commented 1 year ago

Going to close this now that https://github.com/CoreyKaylor/Lightning.NET/pull/157 is merged. Feel free to open again if your findings show there are still problems.

CoreyKaylor commented 1 year ago

Published version 0.15.0 that includes this change.