【发布时间】:2022-07-02 05:06:43
【问题描述】:
是否可以在 Windows docker 容器中运行使用 winforms 的应用程序?我们所有的软件都严重依赖于 winforms,但是可以在不与 GUI 交互的情况下运行所有这些工具。我试图从容器内部调试启动器,我注意到应用程序在 WindowsFormsApplicationBase 基类的 Run 函数处停止。
using Microsoft.VisualBasic.ApplicationServices;
namespace Program
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MyApp myApp = new MyApp();
myApp.Run(args);
}
}
class MyApp : WindowsFormsApplicationBase
}
调用栈
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine) Unknown
MyApp.exe!MyApp.Program.Main(string[] args) Line 49 C#
【问题讨论】:
-
实际上不需要 WinForms 是什么意思?你真的需要 Win Forms 吗?
-
它是使用 WinForms 构建的,但我实际上不需要与 GUI 交互。我也无法修改这些工具中的任何一个,因为它们超出了我的控制范围。
-
this 回答你的问题了吗?
-
很遗憾没有。本周早些时候看到了,但是我已经在使用基于 dotnet/framework/runtime 的图像。我正在通过命令行启动所有内容,但仍然挂断。
-
Windows 容器不支持 GUI。如果应用程序依赖于服务器端的桌面(您在容器或虚拟机或物理主机上运行),那么它将无法在 Windows 容器上运行。如果应用程序有一个不需要 GUI 的服务器组件,并且用户在他们自己的计算机上拥有连接到服务端的 UI,那么这将起作用。
标签: c# windows docker winforms