我有一個在本地 Windows 10 機器上運行良好的 .NET 6 服務。當我使用使用這些影像的多階段 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 存在于我的運行目錄中。
我將帶有二進制檔案的作業正常檔案夾從本地計算機復制到容器中,但出現此錯誤!當我將失敗的檔案夾從容器復制到本地計算機時,它起作用了!
我究竟做錯了什么?我的容器中可能缺少一些東西嗎?
uj5u.com熱心網友回復:
Xbim.Geometry.Engine64程式集依賴于 Visual C 運行時庫中的本機代碼。默認情況下,ASP.NET Windows Server Core 映像不包含這些庫,因此 .NET 運行時在嘗試加載程式集時會失敗,如問題所示。
我們可以通過安裝可再發行包將 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
有關與此程式集相關的其他一些常見依賴問題,請參閱此評論。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/431615.html
