CoreyKaylor / Lightning.NET

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

Error when targeting AnyCPU #104

Closed simon-fisher closed 6 years ago

simon-fisher commented 6 years ago

I get the error below when targeting AnyCPU.

Its thrown from this line of code; LightningDBEnv = new LightningEnvironment(DBPath);

I'm using the latest LightningDB 0.9.9 Nuget package from here; https://www.nuget.org/packages/LightningDB/

Targeting .Net 4.5

Error: "System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)\r\n at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)\r\n at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)\r\n at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)\r\n at GreeterServer.LightningDBEventStore.StoreEvent(String eventKeyName, String eventData) in D:\Projects\TFS\EventStore\grpc\csharp\helloworld\GreeterServer\LightningDBEventStore.cs:line 33"

If I choose x86 or x64 platform, there are no issues. Is there any other workaround so I can use AnyCPU?

Thanks

CoreyKaylor commented 6 years ago

The only way to work around the issue is to write the correct binary to your bin directory given the running architecture. It's a pain, but one that I won't pull into as a concern for this library. Dotnet core does make this experience better in that it selects the right architecture from the nuget.