MacOS 中的 C# windows 应用程序 运行

C# windows application run in MacOS

我只是 C# Windows 表单的新手。现在我有一个上传 txt 文件并输出到 PDF 文件的项目。现在我需要为此使用 C# windows 表单,但我很好奇如果我使用 C# Windows 表单开发它,我是否能够在 Mac[=19 上安装应用程序=] 环境并将其用作我如何在 windows 上使用它?有什么需要考虑的吗?比如我是否需要安装某个软件包才能使其在 Mac 中工作,反之亦然?

I'm just new in C# Windows Form.

嗨!

Now I have a project that Uploads a txt file and output into a PDF file.

继续...

Now I need to use C# windows form for this

不,您不需要使用 WinForms 来简单地上传文本文件和下载 PDF。

but I'm just curious if I develop this using C# Windows form will I be able to install the application on a MacOS environment and use it as how I can use it on windows?

不,你不能。 WinForms 与 Microsoft Windows 操作系统紧密耦合(最大的线索在名称中:Windows Forms。WinForms 是 Windows' 默认窗口控件和小部件(也称为 User32 和通用控件)以及 OLE、COM + ActiveX 和其他以 Windows 为中心的 API。

There are attempts 使 WinForms 的一个子集可以在其他操作系统上运行,但由于 WinForms 本身不是跨平台的,因此您将无法获得对 macOS 主菜单的支持,您的用户将能够说明您的程序外观和感觉不像本机程序。

Are there any consideration needed? Like do I need to install a certain package just to make it work in Mac or vice versa?

不行,不行。

替代方法:

  • 使用 WinForms System.Windows.Forms 制作您的应用程序,并通过某种形式的应用程序远程处理使其可供 macOS 用户使用:
    • 运行 它位于使用 macOS 的远程桌面应用程序访问的 Windows 框中。
    • 运行 它在使用基于浏览器的 RDP 网关访问的 Windows 框上。
    • 运行 它在 Apple Mac(Parallels Fusion、VirtualBox 等)上的 Windows 虚拟机 运行 中。
  • 仅使用 .NET Core 中原生支持的跨平台功能:
    • 使用内置的 http://localhost ASP.NET 网络服务器创建您的应用程序,该服务器托管一个 GUI 网络应用程序,该应用程序可以通过与您的应用程序代码的其余部分交互的网络浏览器访问。
    • 制作仅命令行应用程序。
    • 使用类似 ncurses for .NET 的库制作文本模式 GUI 应用程序。
  • 制作特定于平台的 GUI,同时仍然共享您的应用程序代码的其余部分(例如,使用 Xamarin 从 .NET 使用 Cocoa,在 Windows 上使用 WinForms 或 WPF,GTK# 用于 Linux/BSD, 等等).