Running a .NET Core 2.0 C# module, with OpenCV, in a nanoserver Docker container

1

I have a very basic C# .NET Core 2.0 application which uses a couple of very basic features of OpenCV as a proof of concept.

I'm trying to run this in a nanoserver container, eventually to be deployed as an IoT Edge module, but I get an error saying that it cannot locate a DLL file.

Unhandled Exception: System.TypeInitializationException: The type initializer for 'OpenCvSharp.NativeMethods' threw an exception. --->
System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I have tried compiling with just dotnet publish IoTCoreCSharp.csproj and with dotnet publish IoTCoreCSharp.csproj --runtime win10-x64 --configuration Debug --force, both without luck.

My Docker file looks like this:

FROM microsoft/dotnet:2.0.0-runtime-nanoserver-1709

ARG EXE_DIR=.

WORKDIR /app

COPY $EXE_DIR/ ./

COPY system32_opencvsharp_deps/ C:/Windows/System32

CMD ["dotnet" "IoTCoreCSharp.dll"]

system32_opencvsharp_deps contains avicap32.dll, avifil32.dll, msacm32.dll, msvfw32.dll, and vcruntime140.dll. OpenCvSharpExtern.dll is located in the root of the directory of the DLL file we're executing.

The program runs in a windowsservercore-based image with .NET installed on it perfectly on my development machine, but this kind of image does not run on Windows 10 IoT Core which we need.

Error when trying to run on IoT Core:

c:\Program Files\docker\docker.exe: Error response from daemon: container
e9da3baa806f161153fdb7f60a9401a5ff46c32a959499cbe0bd822b1fc0dda3 encountered an error during Start: failure in a
Windows system call: The compute system exited unexpectedly. (0xc0370106).
opencv
.net-core
docker-for-windows
azure-iot-edge
docker
asked on Stack Overflow Apr 16, 2018 by Hammatt • edited Aug 14, 2019 by Community

1 Answer

0

You can refer to this sample. This sample shows how to run OpenCVSharp in a Windows container with microsoft/dotnet-framework:4.7.1-windowsservercore-1709 as the base image. It indicates the same problem you encountered.

answered on Stack Overflow Apr 17, 2018 by Michael Xu - MSFT • edited Aug 1, 2018 by Peter Mortensen

User contributions licensed under CC BY-SA 3.0