I'm trying to use the FreeImage .NET wrapper in my project, my ptoject targets AnyCPU and the dll wrapper will not work under this, it will only works if I target x86 machine.
When I try to load a file using the wrapper targeting AnyCPU or X64 it throws this exception:
"Se ha intentado cargar un programa con un formato incorrecto. (Excepción de HRESULT: 0x8007000B)" Translated: "Intent to load a program with incorrect format (Excepción de HRESULT: 0x8007000B)"
I've tried to follow the steps to work with x64 freeimage in a net project: http://www.sambeauvois.be/blog/2010/05/freeimage-and-x64-projects-yes-you-can/
...But my VS2012 can't open any of the solutions, it says "can't find localized resources".
The source of freeimage and the wrapper is here: http://downloads.sourceforge.net/freeimage/FreeImage3154.zip
I need the dll converted to work with anycpu targeting, or a other solution to make it work, I'm working with VBNET.
Simplest solution is to use FreeImageNET nuget package. Caveat: I haven't tested this; I don't know how it deals with 32-bit vs 64-bit.
You can do so in your Solution Explorer -
"Manage NuGet packages for Solution...".
Below instructions are for those who wish to build the .NET wrapper themselves.
To clarify Bernhard's answer:
To use FreeImage in a 64-bit project, it isn't enough to compile the ".NET-wrapper"
FreeImageNet.dll as 64-bit.
Must also make sure that you are using 64-bit version of
Note that this is not an "Any CPU" solution. Set your main exe's project Platform to "x64".
FreeImageNet.dll in 64-bit (tested in
VS 2019 Community):
"FreeImage DLL" [WIN32/WIN64]archive from http://freeimage.sourceforge.net/download.html. You DON'T need the "Source distribution", unless you want to build the underlying C++ dll. As I write this, the file you download is
FreeImage\Wrapper\FreeImage.NET\cs\FreeImage.NET.slnin VS; let it convert project format to 2019.
UnitTest project(to avoid errors due to missing NUnit package).
"Treat warnings as errors"to
"None". NOTE: This must be set for each
"Platform"you build. So if you forgot to set Build Platform first, after setting Build Platform to x64, verify that this is still "None".
Releasebuild configurations, if you want to use Debug version with its
FreeImageNET.pdbfor symbols while debugging your app. You'll want the
Releasedll for the Release build of your app.
Optionally, verify that you can build and run Sample 1 in that .sln:
Debug + x64; startup project
binfolder now contains
Sample01.exe. That should also contain a copy of the
FreeImageNet.dllyou previously built.
FreeImage\Dist\x64\FreeImage.dllinto the folder where you found
Program / Mainmethod. Step through, look for any error messages in console window. Most importantly, make sure
FreeImage.IsAvailable()check succeeds - doesn't say "FreeImage.dll seems to be missing".
Now you are ready to repeat this, with your own app:
Debug + x64.
FreeImageNET.pdbinto that folder that contains your
FreeImage\Wrapper\FreeImage.NET\cs\Library\Library.csprojto your solution. This is the "2019 format" version that VS 2019 created for you earlier. This makes it easy to debug into the wrapper sources.
Libraryproject as a dependency, plus
NOTE: Copying those files directly into your bin folder is the "dirty" way to do this. Was easiest way to verify you can build and run with the dlls. Much better is to have those dlls be part of your "sources" under source code control, copied to the bin folder as part of your build process. Google elsewhere for instructions on that.
You need to compile the freeimage library AND the .NET-wrapper to 64 bit.
User contributions licensed under CC BY-SA 3.0