[英].Net Core 2.1 App crashes when deployed to Heroku using Docker
[英].NET service crashes ONLY on Docker
我有一个 .NET 6 服务,它在我本地的 Windows 10 机器上运行良好。 当我使用使用这些图像的多阶段 Dockerfile 在 Docker 上部署它时:
mcr.microsoft.com/dotnet/aspnet:6.0-windowsservercore-ltsc2019 AS base
mcr.microsoft.com/dotnet/sdk:6.0 AS build
...它无法加载我的服务加载的本机 DLL(准确地说是 Xbim.Geometry.Engine64)。
我收到错误:
System.IO.FileLoadException: Failed to load Xbim.Geometry.Engine64.dll
---> System.IO.FileNotFoundException: Could not load file or assembly 'Xbim.Geometry.Engine.dll, Culture=neutral, PublicKeyToken=null'. The specified module could not be found.
File name: 'Xbim.Geometry.Engine.dll, Culture=neutral, PublicKeyToken=null'
这个DLL存在于我的运行目录中。
我将包含我的二进制文件的工作正常的文件夹从我的本地机器复制到容器中,但出现了这个错误! 当我将我的失败文件夹从我的容器复制到我的本地机器时 - 它起作用了!
我究竟做错了什么? 我的容器中可能缺少某些东西吗?
Xbim.Geometry.Engine64
程序集依赖于 Visual C++ 运行时库中的本机代码。 默认情况下,ASP.NET Windows 服务器核心映像不包含这些库,因此 .NET 运行时在尝试加载程序集时失败,如问题所示。
我们可以通过安装可再发行组件 package将 Visual C++ 运行时文件添加到映像中:
RUN powershell -Command Invoke-WebRequest \
-Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" \
-OutFile vc_redist.x64.exe \
&& vc_redist.x64.exe /install /quiet /norestart \
&& del /f vc_redist.x64.exe
对于与此程序集相关的其他一些常见依赖性问题,请参阅此评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.