Search code examples
c#.nethdf5hdf5dotnet

Why won't my .NET app "load file or assembly 'HDF5DotNet'"?


My app is a .NET Windows form app. It calls a function in a C# class library project but I get the following error...…..

"System.BadImageFormatException: 'Could not load file or assembly 'HDF5DotNet, Version=1.8.9.0, Culture=neutral, PublicKeyToken=a4952c8df86d6e8c' or one of its dependencies. An attempt was made to load a program with an incorrect format.'"

HDF5DotNet is a library I pulled in from NuGet.

enter image description here

I have another version of the same .NET solution that has the exact same interface to the exact same HEATMAP project but works perfectly.

It's HEATMAP project is AnyCPU.

On the buggy version, I've set the HEATMAP project to all the other CPU choices, but still get the error.


Solution

  • BadImageFormatException usually means that you're trying to load a 32 bit library into a 64 bit process, or the other way around. Check what version of HDF5 you're trying to load, then set the same bitness for your process (using the dropdown where "Any CPU" is currently displayed).