1
votes

I am developing a service fabric mesh application in .Net Core 2.1, in which Can't use System.Drawing.Common in microsoft/dotnet:runtime (windows container)

Below is my docker file code

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base

WORKDIR /app

EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build

WORKDIR /src

COPY MS_Upload/MS_Upload.csproj MS_Upload/

RUN dotnet restore MS_Upload/MS_Upload.csproj

COPY . .

WORKDIR /src/MS_Upload

RUN dotnet build MS_Upload.csproj -c Release -o /app

FROM build AS publish

RUN dotnet publish MS_Upload.csproj -c Release -o /app

FROM base AS final

WORKDIR /app

COPY --from=publish /app .

ENTRYPOINT ["dotnet", "MS_Upload.dll"]

“Unable to load DLL 'gdiplus.dll': The specified module could not be found. at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromStream(IStream stream, IntPtr& bitmap) at System.Drawing.Bitmap..ctor(Stream stream, Boolean useIcm) at System.Drawing.Bitmap..ctor(Stream stream) at MS_Upload.UserImageMaster.UploadAllChunkImageLibrary(Int32 iPeppyPrintID, Int32 iSourceID, String sAlbumID, Int32 iPickUpOrderID, String sFileName, Int32 iTotalChunk)”

1

1 Answers

0
votes
  • Try using linux container instead as libgdiplus modules aren't installed by default on windows containers, most likely it will work without issues

  • install system.Drawings dependencies using the following commands (reference):

    RUN apt-get update \ && apt-get install -y --allow-unauthenticated \ libc6-dev \ libgdiplus \ libx11-dev \ && rm -rf /var/lib/apt/lists/*

you can use chocolatey to install those dependencies on windows container if using windows image is necessary