在 Docker 容器中加载 dll 时出错,尽管它存在于其中

Error while loading dll in Docker Container although it exists in it

我正在尝试 运行 Docker 上的 .Net 4.72 应用程序。该应用程序在我的计算机上运行完美,但是当我 运行 它在 Docker 容器上时,我收到 error while loading librdkafka.dll or its dependencies from C:\temp\source\bin\x64\Debug\librdkafka\x64\librdkafka.dll. Check the directory exists, if not check your deployment process. You can also load the library and its dependencies by yourself before any call to Confluent.Kafka.

我在该文件夹上使用 dir 命令验证了它的存在

这是我的 Docker 文件的样子:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /source

COPY "./bin/x64/Debug/." "c:/temp/source/bin/x64/Debug/"

RUN powershell.exe dir c:/temp/source/bin/x64/Debug/librdkafka/x64

CMD ["c:/temp/source/bin/x64/Debug/testeh.exe"]

安装 VC++ Runtime

后问题解决
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:\vc_redist.x64.exe /quiet /install