I am using Magick.NET in my project, which renders maps of a game. Is it possible to load the X86 version when I build the tool for x86 processors and the X64 version of Magick.NET for 64bit processors? I guess the the main problem is, that the different versions of the dll have different identities.
I have written a prebuild event which copes the right dll on build, depending on the selected build configuration. I also loaded the copied assembly using Assembly.LoadFrom();, but the app always throws an exception that the assembly I added to references in VS2010 was not found. I can not add both references because they have the same namespace and the same methods.
Is there a better way to handle this except changing the reference in VS2010 for each build configuration?
Prebuild process:
echo."$(ConfigurationName)"|findstr /C:"x64" >nul 2>&1
if not errorlevel 1 (
copy /Y "$(ProjectDir)lib\Magick.NET-x64.dll" "$(TargetDir)lib"
) else (
copy /Y "$(ProjectDir)lib\Magick.NET-x86.dll" "$(TargetDir)lib"
)
Load assembly on x86 build:
if (IntPtr.Size == 4)
{
Assembly assembly = Assembly.LoadFrom("lib/Magick.NET-x86.dll");
}
Exception:
System.BadImageFormatException
Magick.NET-x64, Version=6.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec not found