64 bit does not work

Sep 7, 2013 at 6:31 AM
I have been using MagickImage for about a year now. I have NEVER been able to get any of the 64 bit compiles to work. I always have to use the 32 bit version. This is really a big pain in the butt, because everything I use is 64 bit, EXCEPT MagickImage. When I try to use the 64 bit version, it always give me this error. I've spent honesty dozens of hours trying to find the solution, and NOTHING works. Does anyone here use the 64 bit version? What is the magic fairy dance required to get it to work?

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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Magick.NET-x64' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Stack Trace:


[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.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +523
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +1230
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +616
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +510
System.Reflection.Assembly.Load(String assemblyString) +352
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +501

[ConfigurationErrorsException: 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.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +1497
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +630
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +371
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +327
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +565
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +315
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +406
System.Web.Compilation.BuildManager.ExecutePreAppStart() +431
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1461

[HttpException (0x80004005): 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.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +1038
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +392
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +886


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
Coordinator
Sep 7, 2013 at 7:47 AM
You will receive a BadImageFormatException when you try to load a 64 bit version of Magick.NET in a 32bit application pool. You should disable the option 'enable 32 bit applications' in your application. You should also check your web application to make sure you target x64 instead of AnyCPU.

p.s. Magick.NET has only been available for 5 months, if you are a time traveler then please send me some investment advice.
Sep 19, 2013 at 3:52 PM
I'm having the same problem. How does one "disable the option 'enable 32 bit applications' in Visual Studio 2010 for a vb.net project? I'm running in Windows 7 64bit. I have tried forcing the "x64" compile option for the project. I cannot find any documentation on a command-line compile option or similar approach. I would appreciate any suggestions. Thanks very much.
Great tool by the way - works perfect for projects on my x86 machine.
Sep 19, 2013 at 5:19 PM
Please ignore previous post. The problem was in the 64 bit VC++ redist (using 2010 not 2012). Using the correct redistributable solved the issue completely. Maybe the originator of the question thread made the same mistake?
Coordinator
Sep 19, 2013 at 5:49 PM
Thanks for the information, this will definitely help other users.
Sep 20, 2013 at 8:44 PM
I'm not a time traveler, funny. It sure seems to me that I've either been using this (or a predecessor of sorts) since about this time last year. Something still isn't right, I can't get my project to allow Magick Net in 64 bit mode. I'll keep struggling through it. Your post above did not help.
Coordinator
Sep 20, 2013 at 10:37 PM
Are you using the .NET 2.0 version of Magick.NET? You should install Visual C++ Redistributable for Visual Studio 2008 x64 if you do.
Sep 21, 2013 at 2:10 AM
I think that was the issue. I had both on my development machine, but the target server only had 32 bit. That seems to resolve it! Thanks for your help.