C# Linux上的WPF(已经)可能吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/421764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 02:47:36  来源:igfitidea点击:

Is WPF on Linux (already) possible?

c#.netwpfmono

提问by Hades32

I love programming with .NET, especially C# 3.0, .NET 3.5 and WPF. But what I especially like is that with Mono .NET is really platform-independent.

我喜欢用 .NET 编程,尤其是 C# 3.0、.NET 3.5 和 WPF。但我特别喜欢的是 Mono .NET 是真正独立于平台的。

Now I heard about the Olive Project in Mono. I couldn't find some kind of Beta.

现在我听说了 Mono 中的 Olive 项目。我找不到某种 Beta 版。

Does it already work? Have any of you made any experiences with it?

它已经工作了吗?你们有没有人有过这方面的经验?

Edit: I know about Moonlight. But I want a standalone WPF application. And because ofMoonlight I hope WPF on Linux will become true.

编辑:我知道月光。但我想要一个独立的 WPF 应用程序。而且因为在Linux上月光我希望WPF将成为现实。

采纳答案by Jimmy

You'll have better luck working with Moonlight, which targets the Silverlight API, which is a subset of full WPF.

使用 Moonlight 会更好,它针对 Silverlight API,它是完整 WPF 的子集。

edit: Sure, Silverlight isn't "intended" for the desktop, but there's no reason why you can't embed a silverlight engine in your application. It's been done before, such as for the Mac NY Times Reader

编辑:当然,Silverlight 不是“打算”用于桌面的,但是没有理由不能在应用程序中嵌入 Silverlight 引擎。以前做过,比如Mac NY Times Reader

more edit: see Miguel's post on Standalone Silverlight Applications

更多编辑:请参阅 Miguel 关于独立 Silverlight 应用程序的帖子

回答by Orion Edwards

I heard a podcast interviewing miguel de icaza (the mono lead) maybe a few weeks ago, so that would have been maybe mid-december 2008, and he said that they had no WPF support at all yet.

大概几周前我听到一个播客采访 miguel de icaza(mono 领导者),所以那可能是 2008 年 12 月中旬,他说他们根本没有 WPF 支持。

回答by Kent Boogaart

From the Olive home page:

从 Olive主页

Olive is unsupported, should be considered as experimental software, and since it implements a shifting API there are no guarantees of any kind about the stability of the API.

Olive 不受支持,应被视为实验性软件,并且由于它实现了不断变化的 API,因此无法保证 API 的稳定性。

I doubt anyone would have used it in a real project.

我怀疑有人会在真正的项目中使用它。

回答by trampster

From the mono website

单声道网站

At this point, the Mono project does not have plans to implement Windows Presentation Foundation APIs as part of the project.

此时,Mono 项目没有计划将 Windows Presentation Foundation API 作为项目的一部分实施。

Moonlight is an implementation of silverlight, which is a browser based flash like technology based on a subset of WPF.

Moonlight 是silverlight 的一个实现,它是一种基于浏览器的类似flash 的技术,基于WPF 的一个子集。

In my opinion the choice to not implement WPF is monos biggest mistake. As WPF is fast becoming the default choice for new .net user interfaces. See this blog for more.

在我看来,选择不实现 WPF 是 Monos 最大的错误。由于 WPF 正迅速成为新的 .net 用户界面的默认选择。请参阅此博客了解更多信息

回答by Adam Lassek

Update: Since people keep upvoting this, I want to point out it is longsince out of date. Mono got acquired by MS years ago, and their posture regarding open-source has changed, so consider this post obsolete. (As obsolete as the WPF framework itself, heh).

更新:由于人们不断对此进行投票,我想指出它早已过时了。Mono 多年前被 MS 收购,他们对开源的态度已经改变,所以认为这篇文章已经过时了。(与 WPF 框架本身一样过时,呵呵)。

Mono is in a bit of an uncomfortable position when it comes to Microsoft APIs such as Winforms and WPF. A subset of the .Net technology is an ECMA standard, but free implementations of these APIs are probably on shakier legal ground. I believe this was a large factor in the covenant between Novell and Microsoft, which is good for Novell customers. But people who use Mono that aren't customers of Novell aren't protected. For this reason a lot of people in the F/OSS community look askance at Mono despite its technical merits.

Mono 在涉及 Winforms 和 WPF 等 Microsoft API 时有点不舒服。.Net 技术的一个子集是 ECMA 标准,但这些 API 的免费实现可能基于更不稳定的法律依据。我相信这是 Novell 和 Microsoft 之间契约的一个重要因素,这对 Novell 客户有利。但是,非 Novell 客户的使用 Mono 的人不受保护。出于这个原因,F/OSS 社区中的很多人都对 Mono 不屑一顾,尽管它有技术优势。

For this reason, Gtk# will always be preferred, since it is truly Free. Many people consider it to be superior to Winforms anyway. As far as WPF is concerned, it will almost certainly be a low priority for Novell. They may implement it eventually, but I would expect Moonlight to be the closest you could get for the forseeable future.

出于这个原因,Gtk# 将永远是首选,因为它是真正免费的。无论如何,许多人认为它优于 Winforms。就 WPF 而言,它几乎肯定是 Novell 的低优先级。他们最终可能会实施它,但我希望在可预见的未来,月光是最接近的。



Since posting this, Microsoft has extended their covenant to anybody who implements the ECMA 334 & 335 standards.

自发布此消息以来,Microsoft 已将其契约扩展到实施 ECMA 334 和 335 标准的任何人

回答by Sergii Volchkov

There is a library called Silverform SDKthat aims to provide cross-platform WPF and Silverlight implementation.

有一个名为Silverform SDK的库,旨在提供跨平台的 WPF 和 Silverlight 实现。

The library is implemented in managed code and currently works with OpenTK and Unity3D as render backends. Major functionality, such as binding, layout, main controls and primitives, has already been implemented (check Unity web player demos here). Initially it has been focused on Unity3d render, while support for standalone Mono applications will be added as a separate build in the future.

该库在托管代码中实现,目前使用 OpenTK 和 Unity3D 作为渲染后端。主要功能,例如绑定、布局、主控件和基元,已经实现(在此处查看 Unity 网络播放器演示)。最初它专注于 Unity3d 渲染,而对独立 Mono 应用程序的支持将在未来作为单独的构建添加。

Disclaimer: I am one of the developers of the library.

免责声明:我是该库的开发人员之一。

回答by Dzmitry Lahoda

If you check Known bugs of this link(also includes steps needed to install .NET onto Ubuntu)or thisyou may find that some(may be buggy) version of WPF works on Wine as for now. I did not find any definite test done as for now, but worth to try to run WPF "Hello world".

如果你检查的已知错误此链接(也包括安装.NET上的Ubuntu所需的步骤)或你可能会发现WPF的一些(可能是电瓶车)版本的葡萄酒可以作为现在。我目前没有发现任何明确的测试,但值得尝试运行 WPF“Hello world”。

UPDATE2:

更新2:

I have run latest IlSpyon latest Winefor Ubuntu16.04. With 32 bit version of dotnet45and corefontsinstalled via winetrickswith windows 7 compatibility.

我已经运行了16.04 的IlSpy最新版本。具有 32 位版本并通过与 Windows 7 兼容安装。WineUbuntudotnet45corefontswinetricks

For this time no crashes and all things work fine. Fonts look really good.

这次没有崩溃,一切正常。字体看起来非常好。

IlSpyis shown via WPF and for person who loves programming with .NETis essential tool - the decompiler.

IlSpy是通过 WPF 显示的,并且loves programming with .NET是为必不可少的工具 - 反编译器显示的。

I downloaded latest portable SharpDevelop(build using WPF) with no extra. It started. Failed to create WPF project. Created WinForms. After opening some cs files and evidencing some glitches, tried to type - and it crashed.

我下载了最新的便携式 SharpDevelop(使用 WPF 构建),没有额外的。它开始了。未能创建 WPF 项目。创建了 WinForms。在打开一些 cs 文件并证明存在一些故障后,尝试输入 - 但它崩溃了。

IlSpy via Wine on Ubuntu

在 Ubuntu 上通过 Wine 的 IlSpy

UPDATE

更新

I followed steps and got latest ILSpy.exe running on Ubuntu 14.4.

我按照步骤并在 Ubuntu 14.4 上运行了最新的 ILSpy.exe。

enter image description here

在此处输入图片说明

Next items to note:

接下来要注意的事项:

  1. wine stated that dotnet40 is not supported by 64 configuration, changed to 32 bit

  2. fonts are ugly, but readable

  3. basic functional works fine - I can see decompiled code - which is good enough for some development, but View -> Search and View -> Options -> Display crash.

  1. wine 表示 dotnet40 不支持 64 位配置,改为 32 位

  2. 字体丑陋,但可读

  3. 基本功能工作正常 - 我可以看到反编译的代码 - 这对于某些开发来说已经足够了,但是查看 -> 搜索和查看 -> 选项 -> 显示崩溃。

Conclusion:

结论:

WPF on Linux is possible. But need some way to tackle issues.

Linux 上的 WPF 是可能的。但是需要一些方法来解决问题。

回答by jsantos

Yes, it is possible using NoesisGUIa real-time multi-platform XAML implementation. There are a few games already released using this technology in Linux, like VoidExpanse

是的,可以使用NoesisGUI实时多平台 XAML 实现。已经在 Linux 中使用这种技术发布了一些游戏,比如VoidExpanse

Disclosure: I am one of the developers of this product.

披露:我是该产品的开发人员之一。

回答by Robert Wm Ruedisueli

Theoretically, a stripped version of WPF COULD be compiled against WinPR or LibWine to run on Linux.

理论上,可以针对 WinPR 或 LibWine 编译 WPF 的剥离版本以在 Linux 上运行。

Currently there is no such setup, so someone would need to make one. Hopefully this might change soon.

目前没有这样的设置,所以需要有人做一个。希望这可能会很快改变。

As of running against or in a full Wine environment, I think that is seriously overkill and will result in too much bloat to be worth making a very small number of additional programs work.

至于在完整的 Wine 环境中运行或运行,我认为这是严重的矫枉过正,会导致过多的膨胀,以至于不值得让极少数的附加程序工作。