I'm running a .NET application inside a Windows-based Docker container. The app uses OCCT.NET, and all the required OCCT native DLLs and OCCT .NET DLLs are present inside the image, under the app's bin/Debug/net9.0 folder.
The app runs fine when executed from an IDE like Visual Studio Code, but when trying to make a Windows-based Docker image the runtime throws error "Could not load file or assembly 'C:\app\Occt.NET.dll'. The specified module could not be found."
I have tried the DOCKER EXEC command to verify that the files are indeed in the specified directory, and I also installed the X64 VC_REDIST.EXE in the image.
I also tried with Linux-based Docker images before switching to Windows-based, as I thought maybe the code was incompatible with Linux.
Now I think the issue is likely related to manually placing the external OCCT files and libraries in the bin folder. Normal .NET app Docker images are running fine, but I have a similar problem with my other .NET app that also depends on external libraries.
-
How does your app reference the .dll?SlobodanT– SlobodanT2025年05月12日 20:11:11 +00:00Commented May 12, 2025 at 20:11
-
I have added the Occt.NET package via the "dotnet add package Occt.NET --version 7.9.0" command. But it doesn't automatically brings the dlls in bin folder during build of my app. So, I have put Occt.NET.dll and its relative dlls inside libs folder and mention csproj file of my app to manually copy every dll inside bin folder during build time. Below is snippet form my csproj <ItemGroup> <Reference Include="Occt.NET"> <HintPath>libs\Occt.NET.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <PackageReference Include="Occt.NET" Version="7.8.1.2" /> </ItemGroup>Anshuman Singh– Anshuman Singh2025年05月22日 04:50:21 +00:00Commented May 22, 2025 at 4:50
-
This is working when running from an IDE like VS Code, but I'm not able to run the app in Docker whether Windows based image or Linux. I tried manually copying the dlls inside output directory of docker image but still not working.Anshuman Singh– Anshuman Singh2025年05月22日 04:52:58 +00:00Commented May 22, 2025 at 4:52
-
It looks like you are mixing two types of referencing the same library. Have you tried just using nuget package reference?SlobodanT– SlobodanT2025年05月26日 12:01:52 +00:00Commented May 26, 2025 at 12:01
-
Also it would be good to share the relevant dockerfile for your image.SlobodanT– SlobodanT2025年05月26日 12:02:32 +00:00Commented May 26, 2025 at 12:02