首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在尝试运行imagemagixNET应用程序时使用FileNotFoundException?

在尝试运行imagemagixNET应用程序时使用FileNotFoundException?
EN

Stack Overflow用户
提问于 2013-02-07 16:08:01
回答 1查看 1.3K关注 0票数 0

我正在使用imagemagix.Net动态链接库构建图像转换器应用程序,无论我做什么,只要文件存在,我就会得到这个错误,甚至它会将动态链接库复制到项目调试文件夹。有什么建议吗?错误:

代码语言:javascript
复制
    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:

源代码:

代码语言:javascript
复制
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;
                    }
                }
            }

        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2013-02-07 16:31:26

这是一个漫长的过程,我只是试图将压缩的Tiff图像转换为未压缩的200dpi图像…无论如何,这个问题的解决方案是这样的..**Fabiobr的指令对我来说非常有效,只有一个小插件,所以我将在这里总结:(我使用的是8位版本...只需在以下说明所指的"8“处替换"16”即可)

1)下载此工程并随处解压。2)在您的工程中,引用ImageMagickNET.dll \q8文件夹中的bin。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复制到项目的根文件夹中。(非bin文件夹) 6)将“复制到输出目录”设置为“始终复制”

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

现在,如果帮助文档更好就好了...**

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14746411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档