This project has moved. For the latest updates, please go here.

Magick.NET - Problem with x64-dll

Sep 13, 2014 at 9:11 AM

I am using Visual Studio Express 2013 Web to develop a web-application (MVC 4).

I wanted to integrate Magick.NET (the 64-bit version) in C# but it doesn't work. I tested 2 days long and it's a very frustrating task. I read a lot of information in the web and it seems that I am not the only one with this problem:

This is what I get:

[BadImageFormatException: Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.]

Reading thousand of threads it seems to be that I am trying to load an 64-bit assembly in an 32-bit-environment.

This is what I have done:

I used nuget to install this package: "Install-Package Magick.NET-Q8-x64" (current version, but I already tried older versions - with the same result)

With nuget, a reference in my project is created automatically. In the PROJECT-Settings (not solution) I set the "Platform target:" to x64.

When I am starting the integrated IIS Express Web Server I got the error message posted above.

I am using the .Net Framework 4.5.1 and installed both Microsoft Visual C++ 2012 Redistributable (x64) AND Microsoft Visual C++ 2012 Redistributable (x86). The development-machine uses the 64-bit version of Windows 7. The desired server uses a 64-bit OS as well.

Can anybody help?

Sep 13, 2014 at 9:35 AM
Edited Sep 13, 2014 at 9:36 AM
According to the following post: there seems to be an issue when using Magick.NET x64 in VS2013's IIS Express. I would advise you to stick to 64 bit but you could also switch to AnyCPU as suggested.
Sep 19, 2014 at 4:15 PM
That can't be true how much time I wasted on this problem.

This could be helpful for everyone: By default IIS Express is launched in 32-bit mode in Visual Studio 2013 Express Web. You can verify this behaviour in the task-manager. There is there "*32" annotation for the iisexpress.exe process.

It should be clear that iisexpress.exe can't load a 64-bit dll in 32-bit mode. So you first have to switch the iisexpress.exe to 64-bit mode.

You can do that under the menubar: Tools / Options / Project and Solutions / Web Projects / Use the 64 bit version of IIS Express for web sites and projects.