Yubico/Yubico.NET.SDK

BadImageFormatException when using FindAll or FindByTransport

Closed this issue · 4 comments

Every time I attempt to call either FindAll or FindByTransport I get the following exception,
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=Yubico.Core

Stacktrace: https://gist.github.com/DDX5/71488b1f4e4f0a49d1b5c8bd13a6b9d3

To provide some clarity and to assist in possible debugging steps. I am using the Nuget package version 1.9.1
When I connect using TryGetYubiKey and pass the serial number, it works and returns the YubiKeyDevice.

Hi, can you please provider the .NET version, Operating System, and Processor Architecture you're encountering this error with?

The exception is usually seen when there's a runtime mismatch between our native platform library Yubico.NativeShims.dll and the managed process's runtime identifier. (i.e. 32-bit DLL loading into 64-bit process or vice versa). This should be automatically handled by NuGet and MSBuild, but it doesn't always get it correct.

I am using .NET framework version 4.8, Windows 11 pro and running Zen 3 64 bit architecture.

I have managed to find out the error, by default visual studio and windows forms has an option called prefer 32 bit. When you mentioned about 32 bit trying to load into 64 bit and vice versa I deselected the option and It has fixed the error. May I suggest that you or someone in charge of the sdk docs put a note on there that highlights this problem