【问题标题】:FileNotFoundException when trying to run imagemagixNET app?尝试运行 imagemagixNET 应用程序时出现 FileNotFoundException?
【发布时间】:2013-02-07 08:08:00
【问题描述】:

我正在使用 imagemagix.Net dll 构建图像转换器应用程序,但无论我做什么我都会遇到这个错误。文件存在,甚至它会将 dll 复制到项目调试文件夹。任何建议为什么? 错误:

    System.IO.FileNotFoundException was unhandled
  HResult=-2147024770
  Message=Could not load file or assembly 'ImageMagickNET.dll' or one of its dependencies. The specified module could not be found.
  Source=WindowsFormsApplication1
  FileName=ImageMagickNET.dll
  FusionLog=""
  StackTrace:
       at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WindowsFormsApplication1.Program.Main() in c:\Users\serak\Documents\Visual Studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

源代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ImageMagickNET;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string fileloc;
        MagickNet m;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            MagickNet.InitializeMagick();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MagickNet.InitializeMagick();
            OpenFileDialog fl= new OpenFileDialog ();
            if (fl.ShowDialog() == DialogResult.OK)
            {
                fileloc = fl.FileName;
                using (ImageMagickNET.ImageList im = new ImageMagickNET.ImageList())
                {
                    im.ReadImages(fileloc);
                    int i = 0;
                    foreach (ImageMagickNET.Image image in im)
                    {
                        image.Quality = 100;
                        image.CompressType = ImageMagickNET.CompressionType.LosslessJPEGCompression;
                        image.Write(fileloc.Substring(0, fileloc.LastIndexOf('\\')) + i + ".jpg");
                        ++i;
                    }
                }
            }

        }
    }
}

【问题讨论】:

  • 您可能缺少对所需程序集的引用。检查 ImageMagickNET.dll 需要哪些 DLL
  • 是的,如果它实际上不存在,我使用“使用 Object Brouser 查看”检查了它没有丢失的东西 VS 显示一个黄色错误图标。
  • 我并不是说缺少 ImageMagickNET.dll 引用。我的意思是可能还有其他 DLL,例如:System.Web,ImageMagickNET.dll 需要的,但在您的项目中没有被引用。

标签: c# imagemagick imagemagick.net


【解决方案1】:

IT 的漫长过程我只是想将压缩的 Tiff 图像转换为未压缩的 200dpi 图像......无论如何,这个问题的解决方案就是这个...... **Fabiobr 的说明对我来说非常有效,只有一个小插件,所以我要在这里总结一下:(我使用的是 8 位版本......只要在说明中提到“8”的地方替换为“16”下面)

1) 下载此项目并将其解压缩到任何地方。 2) 在您的项目中,引用 bin\Q8 文件夹中的 ImageMagickNET.dll。 3) 转到http://image_magick.veidrodis.com/image_magick/binaries/ 并下载“ImageMagick-6.5.3-10-Q8-windows-dll.exe” 4) 运行安装,接受所有默认值。 5) 将 C:\Program Files\ImageMagick-6.5.3-Q8 中的所有 DLL 复制到项目的 ROOT 文件夹中。 (不是 bin 文件夹) 6) 将“复制到输出目录”设置为“始终复制”

如果您将 DLL 复制到 bin 文件夹,当您调试(或发布)时,它们将与可执行文件不在同一个文件夹中,并且会出现此错误。通过将它们复制到根文件夹,它们将被复制到与可执行文件相同的目录中。

现在如果只有帮助文档更好...**

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 2018-06-19
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多