Magick.NET: Not working with .NET Core 3 on Alpine Linux

After updating to .NET Core 3 and latest NuGet package, I get the following error:

{
      "Depth": 0,
      "ClassName": "System.TypeInitializationException",
      "Message": "The type initializer for 'NativeMagickSettings' threw an exception.",
      "Source": "Magick.NET-Q8-AnyCPU",
      "StackTraceString": "   at ImageMagick.MagickSettings.NativeMagickSettings..ctor()\n   at ImageMagick.MagickSettings..ctor()\n   at ImageMagick.MagickImage..ctor()\n   at ImageMagick.MagickImage..ctor(Stream stream)\n   at Reshopper.Controllers.MediaController.RedirectToImage(String filePath) in /src/Reshopper/Controllers/MediaController.cs:line 31\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\n   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)\n   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)\n   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)\n   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)",
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "HResult": -2146233036,
      "HelpURL": null,
      "innerException": {
        "Depth": 1,
        "ClassName": "System.DllNotFoundException",
        "Message": "Unable to load shared library 'Magick.Native-Q8-x64.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libMagick.Native-Q8-x64.dll: No such file or directory",
        "Source": "Magick.NET-Q8-AnyCPU",
        "StackTraceString": "   at ImageMagick.Environment.NativeMethods.X64.Environment_Initialize()\n   at ImageMagick.Environment.NativeEnvironment.Initialize()\n   at ImageMagick.Environment.Initialize()\n   at ImageMagick.MagickSettings.NativeMagickSettings..cctor()",
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "HResult": -2146233052,
        "HelpURL": null
      }
    }

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, but I don’t have the time. I’m sure a sample asp.net core app using docker would demonstrate it though!

For me it, this issue appeared again with the mcr.microsoft.com/dotnet/core/aspnet:5.0-alpine image.

@ffMathy: I have updated the title to make this more discoverable.

Thanks for the info @seguins.

I am using Magick.NET (albeit the Q16-HDRI) flavor in .NET Core 3.0 without error. So, most likely a deployment issue. There are some little hiccups here and there in building and deploying .NET Core 3.0 vs 2.0.