I'm trying to containerize a .net framework console application for testing and learning. The application works just fine outside the container.
However, I'm getting this error for every Console.Clear() call:
Unhandled Exception: System.IO.IOException: The handle is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.Console.Clear()
at project.Program.Main(String[] args) in C:\Users\project\Program.cs:line xxx
I can "sort" this out by encasing the Console.Clear() lines in try-catch, but that would be a mess and won't really solve the issue, just hide it under the carpet. I want to understand why is this happening and how to solve it. For propietary reasons I can't post the entire solution here.
This is the dockerfile i'm using:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
ADD "release" "c:/release"
CMD powershell "C:/release/project.exe"
EXPOSE 80 443
I suspect this is because a console is not well handled by a container, but why exactly is the Clear() method of Console falling and not everything else? Why does the container lacks the handler for that particular method? Is it because it's windows core?