AndresTraks / BulletSharpPInvoke

.NET wrapper for the Bullet physics library using Platform Invoke

Home Page:http://andrestraks.github.io/BulletSharp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Working with 64 bit

LPpaolo opened this issue · comments

Dear Andreas,
it is impossible for me run an AnyCpu or 64bit project with the BulletSharp Nuget package.
I can build it but runnning, at the first Bullet function call, I get this error message:
System.BadImageFormatException: 'Tentativo di caricare un programma con un formato non corretto. (Eccezione da HRESULT: 0x8007000B)'
I can however run it in AnyCpu checking prefer 32-bit.
Unfortunately this is not compatible with my project.
Can you please give me some suggestion.
Bye Paolo

BulletSharp is a native library, because it depends on the native libbulletc.dll, which can only be x86 or x64, not Any CPU. Therefore, any project that depends on BulletSharp should also be either x86 or x64. So in your case, the right thing to do is to set it to x64. Maybe you need to restore Nuget packages after switching to the x64 configuration to force it to copy the 64-bit libbulletc.dll?

The Nuget package is currently made so that for an Any CPU project, the x86 version of libbulletc.dll is copied to the bin folder. What happens then is that since your computer is 64-bit, the .NET runtime runs your Any CPU project as x64, but fails to load the x86 libbulletc.dll dependency (BadImageFormatException). On a 32-bit machine, your Any CPU project would run as x86 no problem.

I could make it use the x64 libbulletc.dll for the Any CPU configuration, but then it wouldn't work on a 32-bit computer. Either way, your project configuration needs to match that of libbulletc.dll.

It is correct it works thank you.
I have copied and renamed the library manually, restoring Nuget was still using 32bit dll.
Compliments you ddi a great job with this wrapper.

Thanks!