Docker-Win .NET Core 3.1 Unable to load DLL 'Magick.Native-Q8-x64.dll' or one of its dependencies
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have verified that I am using the latest version of Magick.NET
- I have searched open and closed issues to ensure it has not already been reported
Description
I found many issues regarding this but the solutions that helped others in .NET Core 2.2 Im using Windows Container with image of “mcr.microsoft.com/dotnet/core/aspnet:3.1”.
I also did the step descripbed here to set the NativeLibPath:
string nativeDir = System.IO.Path.Combine(dir, "runtimes", "win-x64", "native");
ImageMagick.MagickNET.SetNativeLibraryDirectory(nativeDir);
Im still getting the error “Unable to load DLL ‘Magick.Native-Q8-x64.dll’” and cant find any error in my dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["Web/MyWebApp/MyWebApp.csproj", "Web/MyWebApp/"]
# Copy last successfull build of ngapp
COPY ["Tools/MyApp/MyApp.csproj", "Tools/MyApp/"]
RUN dotnet restore "Web/MyWebApp/MyWebApp.csproj"
RUN dotnet restore "Tools/MyApp/MyApp.csproj"
WORKDIR /src/
COPY . .
WORKDIR /src/Tools/MyApp
RUN dotnet build "MyApp.csproj" -c Release -o /app/build-m
WORKDIR "/src/Web/MyWebApp"
RUN dotnet build "MyWebApp.csproj" -c Release -o /app/build
FROM build as consoleAppPublish
WORKDIR /src/Tools/MyApp
RUN dotnet publish "MyApp.csproj" -c Release -o /console-app/publish
FROM build as apppublish
WORKDIR /src/Web/MyWebApp
RUN dotnet publish "MyWebApp.csproj" -c Release -o /app/publish
WORKDIR /app/publish/ClientApp/dist
COPY --from=build /src/Web/ngapp .
FROM base as final
WORKDIR /app/
COPY --from=apppublish /app/publish .
COPY --from=consoleAppPublish /console-app/publish /app/consoleapp
COPY --from=build /src/Web/MyWebApp/start-apps.bat .
ENTRYPOINT ["start-apps.bat"]
Steps to Reproduce
Deploy an App referencing to “Magick.NET-Q8-x64”
System Configuration
- Magick.NET version:Magick.NET-Q8-x64 7.22.2.1
- Environment (Operating system, version and so on): Docker, Windows Container, mcr.microsoft.com/dotnet/core/aspnet:3.1
- Additional information:
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Could not load file or assembly 'Magick.NET-x86.DLL' or ...
I have used Magick.NET which is a .NET wrapper for ImageMagick, and it throws the above error on a client machine. It works...
Read more >New packaging requirements for plugins starting with PDN ...
DllNotFoundException: Unable to load DLL 'Magick.Native-Q8-x64.dll' or one of its dependencies: The specified module could not be found.
Read more >Unable to load DLL 'PortableEngine.Native.dll' or one of its ...
Is there no way to open DocumentUltimate with .net core 3.1 windows container? .net framework is meaningless because the image size is too...
Read more >Deep-dive into .NET Core primitives: deps.json ...
NET Core runtime expects to be able to load a file named Newtonsoft.Json.dll when the application is executed. The same is true for...
Read more >After upgrading .net core from 3.1 to 5 I'm getting error in ...
DllNotFoundException: Unable to load shared library 'xxxx/libwoundmeasurementinterface_be.so' or one of its dependencies.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And some more info: the mcr.microsoft.com/dotnet/aspnet image is based off nanoserver, which does not include gdiplus. So far, it doesn’t look possible to add gdiplus to nano server just by copying in a couple of dlls.
What does work is using an image based on server core, with the obvious downside of increasing image size to about 5GB.
While there is no official MS image for 3.1 based on server core, there is one for 5.0.
I’ve successfully verified that using
FROM mcr.microsoft.com/dotnet/aspnet:5.0-windowsservercore-ltsc2019 AS base
no longer throws an exception initializing Magick.NetIf you want a differnt version of the runtime (like 3.1) you’ll have to create your own image - you can base it on the MS dockerfile for 5.0
Thanks! Basing on servercore Magick.NET and other image processing libs work.