Unable to load libwkhtmltox DLL when running on Windows Container Docker

  asp.net-core, c++, dinktopdf, docker, windows

I’m trying to run my project in a Windows Container in Docker but I kept having this kind of error when loading the necessary dll for DinkToPDF:

System.DllNotFoundException: ‘Unable to load DLL ‘C:applibwkhtmltox’ or one of its dependencies: The specified module could not be found. (0x8007007E)’

Already tried the suggested solutions on this threads but still no luck:

https://github.com/rdvojmoc/DinkToPdf/issues/116

https://github.com/rdvojmoc/DinkToPdf/issues/5

Below is my current Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["{ProjectName}/{ProjectName}.csproj", "{ProjectName}/"]
RUN dotnet restore "{ProjectName}/{ProjectName}.csproj"
COPY . .
WORKDIR "/src/{ProjectName}"
RUN dotnet build "{ProjectName}.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "{ProjectName}.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{ProjectName}.dll"]

Source: Windows Questions

LEAVE A COMMENT