This project has moved and is read-only. For the latest updates, please go here.

The type or namespace name 'ImageMagick' could not be found

Feb 14 at 8:43 AM
Hi Dirk,

I am having an unusual error. If I install Magick.Net (latest version 7.0.4.701) from Nuget and select "Q8-AnyCPU" it is working fine. It installs Q8-AnyCPU.dll in "/Bin" folder (size 11 MB) and automatically adds a reference.

However if I only install Q8-x64 from Nuget, I noticed that it does NOT copy Q8-x64.Native.dll to /Bin folder. When I manually copy this file to /Bin folder and add a reference I still get the error "The type or namespace name 'ImageMagick' could not be found".

Now if I uninstall Q8-64 and install Q8-AnyCPU, everything is working fine. Any idea why Q8-x64 from Nuget is not working at all?

Thank you.
Feb 14 at 8:54 AM
Edited Feb 14 at 9:01 AM
Instead of Nuget, I also manually copied the three files from zip files, copied them to /Bin and add a reference (for Q8-x64) and it still gives a "The type or namespace name 'ImageMagick' could not be found" message.

I installed and uninstalled multiple times and still same result.

I also tried steps mentioned in link below, but still same error.
https://magick.codeplex.com/discussions/653835

Also when we manually add a reference, I do not see any links to Magick.NET in web.config file.

I have enabled 64 bit in visual studio as per instruction in this link: https://blogs.msdn.microsoft.com/rob/2013/11/14/debugging-vs2013-websites-using-64-bit-iis-express/

Thank you.
Feb 14 at 3:26 PM
Edited Feb 14 at 3:26 PM
The native dll will be copied to the bin directory when your project is being build. The .targets file that does this should be added to your csproj file.

Are you really sure that your application is running in 64 bit? It feels like you are getting this error because your application is 32-bit. Which version of the library do you see in this folder: %temp%\Magick.NET.net40-client.7.0.4.701? That folder is created by the AnyCPU library.
Feb 14 at 8:20 PM
Are you really sure that your application is running in 64 bit?
Yes, I verified it in three different ways:
  1. From visual studio: Tools | Options | Projects and Solutions | Web Projects | Use the 64 bit version of IIS Express
  2. Using code:
if (IntPtr.Size == 8) 
{    // 64 bit machine
} 
else if (IntPtr.Size == 4) 
{    // 32 bit machine
}
  1. More code:
Environment.Is64BitProcess
Code taken from: http://stackoverflow.com/questions/266082/how-do-i-tell-if-my-application-is-running-as-a-32-bit-or-64-bit-application
Which version of the library do you see in this folder: %temp%\Magick.NET.net40-client.7.0.4.701? That folder is created by the AnyCPU library.
I cleaned up the %temp% folder and when I installed AnyCPU from Nuget, there are are no Magick.NET folders created within the %temp% folder.
The native dll will be copied to the bin directory when your project is being build. The .targets file that does this should be added to your csproj file.
In visual studio, I created it as a "Web Site" instead of "Web Application Project". Hence I do not have a .csproj file. The "Web Site" (as you know) automatically compiles all files dynamically on run time.

Environment: Windows 10, Visual studio 2015 community edition update 3 running .Net Framework 4.6.2.

Is there any other info I can provide? Please let me know. Thank you.
Feb 16 at 8:13 PM
What happens when you use a Web Application Project instead of a Web Site? I haven't used the latter one in ages so I assumed you were using the csproj version. I'll try to see I can set up a web site project this weekend. I don't understand why there are no Magick.NET folders in your %TEMP% folder. You should have the following folder there: Magick.NET.net40-client.7.0.4.701. Can you see if it is somewhere else on your machine?
Feb 17 at 2:23 AM
After many installs and uninstalls, I finally noticed the "Magick.NET.net40-client.7.0.4.701" folder appear in %Temp%

It has the "Magick.NET-Q8-x64.Native.dll" file in it (in addition to 12 other files such as configure.xml, english.xml, etc). So I am guessing that confirms 64-bit. Please let me know if you need any other info? Thank you. :)
Feb 21 at 9:54 PM
Will try to create a test project later this week and see if I can reproduce your issue.
Feb 27 at 8:16 PM
I can reproduce your issue. It seems that the project does not want to create a link to the library. But I don't understand why this is happening. Will take another look at this again in a couple weeks.
Feb 27 at 11:05 PM
Thanks for confirming the bug, Dirk.
Feb 28 at 8:53 AM
I don't think this is a bug in Magick.NET though. I think we will need to configure the website project in some way. Just not sure how we should do that.