NET Core 使用 Docker 发布 ,二维码显示错误

warn: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
      No output formatter was found for content types 'image/jpeg, image/jpeg' to write the response.
fail: Core.Api.Filter.GlobalExceptionsFilter[0]
      The type initializer for 'Gdip' threw an exception.
      【自定义错误】:The type initializer for 'Gdip' threw an exception. 
      【异常类型】:TypeInitializationException 
      【异常信息】:The type initializer for 'Gdip' threw an exception. 
      【堆栈调用】:   at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)
         at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
         at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule, Color darkColor, Color lightColor, Boolean drawQuietZones)
         at Core.Api.Common.QRCode.RaffQRCode.GetQRCode(String url, Int32 pixel)
         at Core.Api.Api.Controllers.QRCodeController.GetCode(String url, Int32 pixel)
         at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.<WrapVoidMethod>b__0(Object target, Object[] parameters)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)


原文 https://www.cnblogs.com/youngsheep/p/11890069.html

Dockerfile 配置如下

 
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base 
WORKDIR /app
 
COPY . /app

RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
EXPOSE 8088
 
ENV TZ="Asia/Shanghai"

 
ENTRYPOINT ["dotnet", "Core.Api.Api.dll"]

posted @ 2021-08-12 18:07  泰然4路T王  阅读(226)  评论(0)    收藏  举报
Title