我在mvc3 Web应用程序中使用Magick.net库,这些是我做的步骤
我的项目目标是AnyCPU,我的机器是64位 将Magick.NET-x64.dll的引用添加到项目中。 从此处安装Visual Studio 2012 Update 4的Visual C ++ Redistributable http://www.microsoft.com/en-us/download/details.aspx?id=30679 在机器上安装了Ghostscript 9.14 for Windows(64位) 加入
<add assembly="Magick.NET-x64, Version=7.0.0.0002, Culture=neutral, PublicKeyToken=2004825badfa91ec" />
在web.config文件
上项目已成功重建[并且所有dll也在bin文件夹中],但在运行时我得到例外
无法加载文件或程序集“Magick.NET-x64”或其依赖项之一。尝试加载格式不正确的程序。
描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取更多信息&gt;关于错误以及它在代码中的起源。
异常详细信息: System.BadImageFormatException:无法加载文件或程序集“Magick.NET-x64”或其依赖项之一。尝试是>用于加载格式不正确的程序。
来源错误:
在执行当前Web请求期间生成了未处理的异常。关于&gt;的来源和位置的信息。可以使用下面的异常堆栈跟踪来识别异常。程序集加载跟踪:以下信息有助于确定无法加载程序集“Magick.NET-x64”的原因。
=== Pre-bind state information === LOG: DisplayName = Magick.NET-x64 (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: Magick.NET-x64 | Domain ID: 6 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/Fagbokforlaget/SourceCodes/fbf_internal/picsilo/Source/ImageTagger/ LOG: Initial PrivatePath = C:\Fagbokforlaget\SourceCodes\fbf_internal\picsilo\Source\ImageTagger\bin Calling assembly : (Unknown). LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Fagbokforlaget\SourceCodes\fbf_internal\picsilo\Source\ImageTagger\web.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/jibinmathew/AppData/Local/Temp/Temporary ASP.NET Files/root/a5b5e44f/dc1c4c69/Magick.NET-x64.DLL. LOG: Attempting download of new URL file:///C:/Users/jibinmathew/AppData/Local/Temp/Temporary ASP.NET Files/root/a5b5e44f/dc1c4c69/Magick.NET-x64/Magick.NET-x64.DLL. LOG: Attempting download of new URL file:///C:/Fagbokforlaget/SourceCodes/fbf_internal/picsilo/Source/ImageTagger/bin/Magick.NET-x64.DLL. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
答案 0 :(得分:12)
@dlemstra对blog post的修订是我找到的最简单的解决方案:
在VS2013 / 2015中,转到工具 - &gt;选项 - &gt;项目和解决方案 - &gt; Web项目并选择“将64位版本的IIS Express用于网站和项目。”
答案 1 :(得分:7)
在Visual Studio 2013的IIS Express中运行64位版本的Magick.NET似乎存在问题。您需要set a registry key根据以下答案“High quality JPEG compression with c#”。您可以设置此标志或切换到Magick.NET的AnyCPU版本。
答案 2 :(得分:1)
确保还安装了可再发行的C ++包。
https://magick.codeplex.com/documentation
确保已安装Visual C ++ Redistributable for Visual 工作室
.NET 4.0: Visual C++ Redistributable for Visual Studio 2015 (x64 or x86) .NET 2.0: Visual C++ Redistributable for Visual Studio 2008 (x64 or x86).