Question

i was building image convertor app using imagemagix.Net dll and i get this error what ever i do ..the thing the file exists and even it copies the dll to project debug folder . any suggestion why? error:

    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:

Source Code :

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;
                    }
                }
            }

        }
    }
}

No correct solution

OTHER TIPS

IT's Long Way Process i was just trying to convert compressed Tiff image to uncompressed 200dpi image... anyways the solution to this problem is this.. **Fabiobr's instructions worked perfectly for me, with one little addon, so I'm going to sum up here: (I'm using the 8-bit version... just substitute "16" wherever the instructions refer to "8" below)

1) Download this project and unzip it anywhere. 2) In your project, make a reference to the ImageMagickNET.dll in the bin\Q8 folder. 3) Go to http://image_magick.veidrodis.com/image_magick/binaries/ and download 'ImageMagick-6.5.3-10-Q8-windows-dll.exe' 4) Run the install, accepting all the defaults. 5) Copy ALL the DLL's in C:\Program Files\ImageMagick-6.5.3-Q8 to the ROOT folder of your project. (not the bin folder) 6) Set "Copy to Output Directory" to "Copy always"

If you copy the DLL's to the bin folder, they will not be in the same folder as the executable when you debug (or publish) and will get this error. By copying them to the root folder, they will be copied to the same directory as the executable.

Now if only the help docs were better...**

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top