【发布时间】:2021-12-02 22:35:16
【问题描述】:
我正在 .NET Core 3.1 中编写 AWS Lambda 函数。我在 AWS Lambda 函数中使用 Aspose.slides 库。我将 AWS lambda 函数发布为 AWS 上的 docker。 Lambda 函数成功发布,但是当我测试 Lambda 时,它给了我以下错误:
Aspose.Slides.PptxReadException: The type initializer for 'Gdip' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
尽管,我正在从 docker 文件安装 libgdiplus 包,但我仍然收到上述错误。
Docker 文件是:
FROM public.ecr.aws/lambda/dotnet:core3.1 AS base
FROM mcr.microsoft.com/dotnet/sdk:3.1 as build
WORKDIR /src
COPY ["Lambda.PowerPointProcessor.csproj", "base/"]
RUN dotnet restore "base/Lambda.PowerPointProcessor.csproj"
WORKDIR "/src"
COPY . .
RUN apt-get update && apt-get install -y libc6-dev
RUN apt-get update && apt-get install -y libgdiplus
RUN dotnet build "Lambda.PowerPointProcessor.csproj" --configuration Release --output /app/build
FROM build AS publish
RUN dotnet publish "Lambda.PowerPointProcessor.csproj" \
--configuration Release \
--runtime linux-x64 \
--self-contained false \
--output /app/publish \
-p:PublishReadyToRun=true
FROM base AS final
WORKDIR /var/task
COPY --from=publish /app/publish .
CMD ["Lambda.PowerPointProcessor::Lambda.PowerPointProcessor.Function::FunctionHandler"]
任何帮助将不胜感激。
【问题讨论】:
-
我面临同样的问题。有什么解决办法吗?
-
@SayedUzZaman 为我解决问题的 docker 文件已发布为答案。
-
我正在使用 mcr.microsoft.com/dotnet/core/aspnet:3.1 AS 运行时,在我的情况下应该怎么做?任何提示都会有所帮助。
标签: amazon-web-services docker aws-lambda dockerfile asp.net-core-3.1