I've seen the ticket “Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies” by Harsh Gupta and I'm having the same problem but without those solutions working for me.
I have an web application including ImageMagick that is freshly installed on a new Windows Server 2012 instance (that we're migrating to from a Windows Server 2008 R2 instance). The application runs ok on Server 2008 and locally, but not on Server 2012.
I have rebuilt the project after upgrading Magick.Net from 6.8.7.502 to 7.0.7.300, in the hope that the .Net Standard / .Net Core support mentioned in the Readme, introduced in 7.0.6, would solve my problem, but to no avail. Before doing that, I had also installed VC++ 2012 and 2015 as Harsh Gupta mentioned in their accepted answer.
Despite all this, I'm still getting a "HTTP Error 500.0 - Internal Server Error" page, telling me:
Module: AspNetInitializationExceptionModule
Notification: BeginRequest
Handler: ExtensionlessUrlHandler-Integrated-4.0
Error Code: 0x00000000
Requested URL: [redacted]
Physical Path: [redacted, but correct]
Logon Method: Not yet determined
Logon User: Not yet determined
The Event log shows a Warning event from ASP.NET 4.0.30319.0 with an Event ID of 1310 and the following Stack trace:
Event code: 3008
Event message: A configuration error has occurred.
Event time: 9/20/2017 6:20:40 PM
Event time (UTC): 9/20/2017 6:20:40 PM
Event ID: 4775ecdb4601401ca30aa057f77ae78a
Event sequence: 1
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: [redacted]
Trust level: Full
Application Virtual Path: /
Application Path: [redacted]
Machine name: [redacted]
Process information:
Process ID: 5096
Process name: w3wp.exe
Account name: IIS APPPOOL\[redacted]
Exception information:
Exception type: ConfigurationErrorsException
Exception message: Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
Request information:
Request URL: [redacted]
Request path: /
User host address: [redacted]
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\[redacted]
Thread information:
Thread ID: 8
Thread account name: IIS APPPOOL\[redacted]
Is impersonating: False
Stack trace: at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Custom event details:
Looking in the webroot, the bin folder does contain Magick.NET-x86.dll (and Magick.NET-Q16-x86.dll and Magick.NET-Q16-x86.Native.dll), and the IIS_IUSRs group does have read access to these DLLs (and all the others).
While it is a 64-bit server, the AppPool does have Enable 32-bit applications set to True. Changing the AppPool's Managed Pipeline Mode from Integrated to Classic also has no effect. I do note, however, that the number of applications for the AppPool is listed as zero (despite the website's advanced settings dialog showing the correct AppPool name):

I am completely at a loss and we are behind schedule on the migration of this application now, so any suggestions would be gratefully received.
Thanks!
Edited to add: There is a little more information at ticket #107 on Github.
I don't have an answer but a few ideas on troubleshooting, although you probably tried these.
Maybe you've tried all that but hopefully it might help give you another direction, even if it doesn't help directly.
Try using the Global Assembly Cache Tool (gacutil.exe) to publish the missing assembly to the GAC:
gacutil.exe /i Magick.NET-x86.dll /f
gacutil.exe /i Magick.NET-Q16-x86.dll /f
gacutil.exe /i Magick.NET-Q16-x86.Native.dll /f
The .NET runtime scans for assemblies in the GAC when it cannot locate an assembly referenced by the project at a local path. We typically use the GAC for assemblies shared by several applications, but we can try this approach for troubleshooting.
If the application in question runs successfully after publishing these assemblies to the GAC, there may be a problem with the assembly reference properties in the project that uses them.
After testing, we can remove the assemblies that we added from the GAC:
gacutil.exe /u Magick.NET-x86
...
gacutil.exe comes with the .NET Windows SDK. To avoid installing this on the server, we can use PowerShell to install the assemblies:
[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") > $null
[System.EnterpriseServices.Internal.Publish] $publisher = new-object System.EnterpriseServices.Internal.Publish
$publisher.GacInstall('Path\To\Magick.NET-x86.dll')
Both tools require administrator privileges on the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With