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

Can not load the file 'Magick.NET.Wrapper-x86.DLL'

Oct 5, 2015 at 4:27 PM
Hello,

In my computer i tried my code with a Application Windows and it's working fine.

I try to do the same thing in an asp.net website and when i launch it in localhost i have the message in subject of this topic.

The 3 references was in the project (Magick.NET-x86, Magick.NET.Core and Magick.NET.Wrapper).

What i'l doing wrong ?

The asp.net project is build to x86 with .net 4.0 framework.
Oct 5, 2015 at 4:28 PM
Edited Oct 5, 2015 at 4:29 PM
the stack trace (sorry is a french project) :
[FileNotFoundException: Impossible de charger le fichier ou l'assembly 'Magick.NET.Wrapper-x86.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Impossible de charger le fichier ou l'assembly 'Magick.NET.Wrapper-x86.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): Impossible de charger le fichier ou l'assembly 'Magick.NET.Wrapper-x86.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9951956
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456
Oct 5, 2015 at 5:52 PM
Did you install the C++ Redistributable? You need this to run Magick.NET at the moment. The next version will use the Universal CRT that comes with Windows update. I will try to publish a new release this weekend. You could get this version as a 'dev' build from the following NuGet feed: https://ci.appveyor.com/nuget/Magick.NET. Be sure to upgrade to the official release when that has been published.
Oct 6, 2015 at 10:16 AM
Yes the c++ redistribualable is inslatted (x86 + x64).

I try the dev build but i have the same error.

I have tried many configurations (anycpu, x86 and w64) and the only configuration wich allows to launch the website is :
Website project target : AnyCpu
Magick .NET : Q16 AnyCPU

But when i try to create a nesw instance of MagickImageCollection i have a message : Can not load the file or assembly Magick.NET.Wrapper-x86, Version=7.0.0.0, Culture=neutral,PublicKeyToken=2004825badfa91ec
Oct 6, 2015 at 11:06 AM
You probably want to change the AnyCPU temp directory:
MagickAnyCPU.CacheDirectory = @"C:\MyProgram\MyTempDir";
Oct 6, 2015 at 11:13 AM
the exception is raised when i hit the 1st line of this code :
            using (var images = new MagickImageCollection())
            {
                var template = new MagickImage(templateFilename);
                images.Add(template);

                var pivot = new MagickImage(pivotFilename);
                images.Add(pivot);

                template.Composite(pivot, CompositeOperator.Overlay);
                template.Write(resultFilename);
            }
Oct 6, 2015 at 11:46 AM
Did you set the MagickAnyCPU.CacheDirectory at the start of your application?
Oct 6, 2015 at 12:45 PM
yeah like it :
           MagickAnyCPU.CacheDirectory = @"D:\Temp";

            using (var images = new MagickImageCollection())
            {

...
Oct 6, 2015 at 12:54 PM
Are there any files written to the CacheDirectory?
Oct 6, 2015 at 12:56 PM
Edited Oct 6, 2015 at 12:57 PM
Yes, below the list files in cahce directory
coder.xml
colors.xml
configure.xml
delegates.xml
english.xml
locale.xml
log.xml
magic.xml
Magick.NET-Q16.Wrapper-x86.dll
policy.xml
thresholds.xml
type-ghostscript.xml
type.xml
Oct 6, 2015 at 12:58 PM
That looks good. Which version of the redistributable did you install, the VS2012 version? And did you reboot your machine after the installation?
Oct 6, 2015 at 1:00 PM
yes, the vs2012 (both x86 and x64).

but i'm using visual studio 2010 with 4.0 framework.

no reboot.
Oct 6, 2015 at 1:14 PM
A reboot might do wonders... :)
Oct 6, 2015 at 1:43 PM
same error after reboot. :(
Oct 6, 2015 at 1:55 PM
Just to be clear.. you are no longer using the dev build? And you are now using the .NET 4.0 version of Magick.NET?
Oct 6, 2015 at 1:57 PM
no, i'm using "Magick.NET-dev-Q16-AnyCPU" whith a ASP.NET 4.0 Project.
Oct 6, 2015 at 2:13 PM
You need the universal CRT if you are running Magick.NET-dev-Q16-AnyCPU. If you are on a new machine you should have the following Windows update installed: https://support.microsoft.com/en-us/kb/2999226. On my company machine this seems to be an optional update.
Oct 6, 2015 at 2:21 PM
Edited Oct 6, 2015 at 2:43 PM
same error after installing the universal CRT.

why it's trying to load the Magick.NET.Wrapper-x86 dll in a x64 machine ?
Oct 6, 2015 at 3:15 PM
Your application pool is 32-bit or your project has the flag 'Prefer 32-bit' enabled.
Oct 6, 2015 at 3:19 PM
I don't have the "Prefer 32-bit" option because i'm on VS2010.

But you're right my pool application is 32-bit, and i can't change it !

It's due of old dependecies in the project.
Oct 7, 2015 at 3:34 PM
I can reproduce the issue with the dev build on my company machine. I will investigate this when I am home.
Oct 7, 2015 at 3:40 PM
cool, i'm sure you will find a solution ! ;)
Oct 7, 2015 at 8:25 PM
It appears you still need to install the C++ redistributable. You can download that here: https://www.microsoft.com/en-us/download/details.aspx?id=48145
Oct 8, 2015 at 10:22 AM
after install an reboot i have the same error.
Oct 8, 2015 at 11:17 AM
Did you install the x86 version? It works on my company machine after the installation.
Oct 8, 2015 at 12:07 PM
yes
Oct 21, 2015 at 7:35 PM
I am having the same problem. Any solution found? Thanks
Oct 22, 2015 at 8:16 AM
Did you install the Visual C++ redistributable for Visual Studio 2015? This is required for the latest version of Magick.NET
Oct 29, 2015 at 4:43 PM
I am experiencing the same issue on a client machine. It works fine on my local machine because I have the redistributable installed. However I don't have that option on my target machines.
Is it possible to setup Magick.NET to use with an app-local deployment of the redistributable files?
I attempted adding the files from the universal crt to my project and deploying them that way, but it didn't seem to work. Do you have any suggestions?
Oct 30, 2015 at 10:47 AM
Can't you bundle the C++ redistributable with your installer? Thats what I do in the ClickOnce configuration for MagickViewer.
Oct 30, 2015 at 1:47 PM
Wouldn't this require user interaction and administrative rights?
I use ClickOnce as well, though I haven't yet learned how to setup prerequisites.
If I'm wrong, then great! However, it is an design requirement that it has to be seamless and invisible to the end users the majority of whom do not have any system rights.
Oct 30, 2015 at 3:40 PM
I think you need administrative rights for this. Maybe your executable could check the registry and see if it is installed (simple example: http://blogs.msdn.com/b/astebner/archive/2010/05/05/10008146.aspx). And if it is not then installed tell the user where to download it or tell them they need to contact their IT support staff to get it installed. I think your application won't complain about the library until you call/use one of the classes in the Magick.NET library.

You could also decide to use the .NET 2.0 build since that requires the VS 2008 redistributable and it is very likely that it is installed on a system these days.

I don't think you can make it invisible to the end user at this point. But please let me know if you figure out a way how to do this.
Oct 30, 2015 at 3:57 PM
Unfortunately its a zero tolerance policy.
I think its likely switching to 2008 would fix the issue however since I would be able to locate the files and could easily do an app-local deployment.
I'll keep this in mind for the future.
However I was asked to switch to a library we have a license for so I can't spend time testing this.
I may revisit this in the future however as the Magick.NET library provides a wider array of functionality that could be useful in our software.
If I do then I will make sure to update this discussion with my findings.