【发布时间】:2021-06-15 17:03:38
【问题描述】:
我正在尝试在容器中运行 Windows 控制台应用程序(.net 核心)。它在主机上运行良好,但是一旦我运行 docker 容器,它就会抛出这个 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 文件
# 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"]
我还需要在容器中安装其他东西吗?
【问题讨论】:
-
您可能正在使用 linux 容器,然后尝试访问 windows 特定的 API,这在 linux 环境中当然不会工作。
-
@Henkolicious,我在 Windows 上运行它。
标签: docker .net-core containers console-application