![](/img/trans.png)
[英].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.