I am attempting to run a .NET framework application that executes C++ code using DLLImport in a Windows container. The application runs fine locally on my Windows 10 machine but in the Windows container I am getting a System.DllNotFoundException. I executed a dumpbin \dependents on the Dll in question and it appears that I don't have the following Dlls in my container
MSVCP140D.dll
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
My DockerFile is as follows
FROM mcr.microsoft.com/windows/servercore:ltsc2019
ADD https://aka.ms/vs/16/release/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:\vc_redist.x64.exe /install /passive /norestart /log out.txt
COPY ./bin/Debug/ .
ENTRYPOINT ["C:\\Program.exe"]
Could anyone be able to help me out with my DockerFile. I presumed installing vc_redist.x64.exe would do the trick for me but it did not.
Related
I want to install .netframework 4.7.1 Developer offline pack in windows server core 2019 through docker and run it in a windows container. I have tried this command but no use in my Dockefile by copying it from my local directory to container.
**RUN start /w .\dotnet-framework-installer.exe /q **
I have downloaded .net framework dev pack from this site (https://dotnet.microsoft.com/en-us/download/dotnet-framework/net471)
I want to know which command to use in Dockerfile, so it can install in a container.
I have found the solution. You can find the dockerfile to install a developer pack offline mode in below git hub repo https://github.com/hrushikesh2000/Docker_Dev_pack-insta-.git.
I'm trying to change the permissions in a windows docker container to give admin access in the dockerfile so it can run some powershell scripts. In order to do this I'm using some commands found in the microsoft.powershell.localaccounts core module and I've found those commands to work in a base image that has that module installed in its version of powershell but sadly the base image I'm currently using doesn't have it and I need to use this version for size reasons.
I've tried running this line in the windows docker container via powershell but while it seems to run properly with no issues printing out it still isn't installed.
Find-Module -Name microsoft.powershell.localaccounts | Install-Module -SkipPublisherCheck
I am trying to run a windows console application (.net core) in a container. It is working fine on host but as soon as I run the docker container, it throws this error:
The type initializer for 'MyApp.Utility.SystemEventsHandler' threw an exception.
---> System.Runtime.InteropServices.ExternalException (0x80004005): Failed to create system events window thread.
at Microsoft.Win32.SystemEvents.EnsureSystemEvents(Boolean requireHandle)
at Microsoft.Win32.SystemEvents.add_SessionEnding(SessionEndingEventHandler value)
Docker File
# getting base image
FROM mcr.microsoft.com/dotnet/runtime:3.1
# copy files
COPY app/ app/
# set working directory
WORKDIR app
# entry point
#ENTRYPOINT ["dotnet","MyApp.dll"]
Do I need to install something else too in the container ?
The problem is not that you are running the console app on a windows OS host with docker. The problem is that you are running a linux container (very slim version of a linux OS) and then trying to access windows specific APIs.
As the error states Failed to create system events window thread. at Microsoft.Win32.SystemEvents...
That is why the application is working just fine when you debug it on your windows OS host, but not in a linux container. You will get the same effect if you deploy it to a regular linux host or trying to run it in WSL for example.
One thing that might work is switching to a windows container, but I don't know how your code looks. To switch to windows container, I think you simply right click the system tray icon for docker desktop and swap. But I've never used windows containers, so I would not know.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-5.0#run-in-a-windows-container
PS I hope you are not trying to run a GUI application in docker, that is not supported.
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).
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.
I have published an asp.net vnext application using,
dnu publish --runtime 1.0.0-rc1-update1 --framework dnxcore50 --no-source
after this If I generate a docker container,
FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr
ADD ./bin/output/approot /app WORKDIR /app
EXPOSE 8080 ENTRYPOINT ["./web1"]
If I run this using "docker run" command, then I see there is a problem with System.Net.Security. I also read some related issues with deploying to Linux, + some blogs which instruct on how to do "dnu publish" with linux runtime in a LINUX OS (ex: Ubuntu).
If I have to build in a LINUX OS to target LINUX, then that beats the purpose of cross-platform. In some blogs I also read, just by doing dnu restore from the source it will be good enough, problem is I have a complicated source folder setup, and I don't want to write long build scripts for Dockerfile that will help me copy all the required source + dependent source projects, and then create a DNX image of the app (very tedious).
Does anyone have a simple solution for this?
I found the issue was with the nuget packaging for System.Net.Security package.
https://www.nuget.org/packages/System.Net.Security/4.0.0-beta-23516
This version doesn't include the package for dnxcore50, but the one previous to that has it defined,
https://www.nuget.org/packages/System.Net.Security/4.0.0-beta-23409
Downgraded to use this and this issue is solved. Doh! silly issues by the MS team.