I'm trying to run a .net 4.8 application written in C# in a windows docker container.
I'm using eyeshot 2021
Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
COPY . .
Application code:
using devDept.Eyeshot;
namespace My.Last.App
{
public class DWGHandler
{
private readonly Model _model;
public DWGHandler()
{
_model = new Model();
}
}
}
Exception:
Unhandled Exception: devDept.Graphics.GraphicsException: Error: ChoosePixelFormat() failed.
at devDept.Graphics.OglRenderContext.#=z0FbIHr$gLtUs(IntPtr #=zac5AdAIe8BUn, Int32 #=z0LtyIiZ9tI$1, ControlData #=z9Lxqa$4=, IntPtr& #=zsqxxH_UY7CKb)
at devDept.Graphics.OglRenderContext.Create()
at devDept.Eyeshot.Environment.OnHandleCreated(EventArgs e)
at devDept.Eyeshot.EnvironmentBase.OnLoaded(Object sender, EventArgs e)
I have no idea what I'm doing wrong. This works fine on a windows machine, but not in a docker container. Is there a magic switch I missed to make it work?
Edit 1:
After checking the last error, I can see:
GetLastError returned 0x7f
Which probably means:
ERROR_PROC_NOT_FOUND
127 (0x7F)
The specified procedure could not be found.
The "windowsservercore" images do not have the (graphical) components/dlls needed by Eyeshot.
There is two options:
Option 1:
Create your own image and use the 'full' windows base image: 'mcr.microsoft.com/windows:'
Make sure to install .NET 4.8 and the VC2019 Redistributable package
Note: this will be a VERY LARGE image!
Option 2:
(we are using this option successfully, resulting in much smaller image sizes)
Create your own image based on 'windowsservercore'
Install .NET 4.8 and the VC2019 Redistributable package
Copy the following files into c:\windows\system32 (using a copy step in your Dockerfile):
Make sure to grab these files from a full windows version, matching the windowsservercore version. (so if using windowsservercore-ltsc2019 (10.0.17763.3887), grab these files from a Windows image with the exact same 'OsVersion', in this case 'windows-1809').
You can compare OsVersion of 'Windows' releases and 'windowsservercore' releases here:
Good luck!