我们可以在 Mac OS X 上运行 C#/WPF 应用程序吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/580970/
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
Can we run a C#/WPF application on Mac OS X?
提问by Nir
I sell a C#/WPF application (targeting .net 3.0 at the moment) and people keep asking me for a Mac version.
我卖了一个 C#/WPF 应用程序(目前针对 .net 3.0),人们不断向我索要 Mac 版本。
The application is a time tracking application with a good GUI, there isn't that much business logic in a time tracking application so most of the application is GUI - rewriting just the GUI is equivalent to rewriting the entire application
该应用程序是一个具有良好 GUI 的时间跟踪应用程序,时间跟踪应用程序中没有那么多业务逻辑,因此大部分应用程序都是 GUI - 仅重写 GUI 就相当于重写整个应用程序
I don't have the resources to rewrite the application or maintain two different code bases, so I need a way to run the same code on a Mac (I know I'll have to debug and modify the code, what I mean is I can support only one code base, I can't split the project into different Mac and Windows projects - I just don't have the time to work on two projects).
我没有资源来重写应用程序或维护两个不同的代码库,所以我需要一种在 Mac 上运行相同代码的方法(我知道我必须调试和修改代码,我的意思是我只能支持一个代码库,我无法将项目拆分为不同的 Mac 和 Windows 项目——我只是没有时间处理两个项目)。
Porting the application to a cross-platform UI library, to a different programing language or to Silverlight are all not relevant - it will take too much time and I think I'll get more sales by investing this time in new features.
将应用程序移植到跨平台 UI 库、不同的编程语言或 Silverlight 都无关紧要 - 这将花费太多时间,我认为通过这次投资新功能,我会获得更多销售。
Does anyone know of a tool that can run or port C#/WPF to the Mac?
有谁知道可以运行 C#/WPF 或将 C#/WPF 移植到 Mac 的工具?
回答by Anton Gogolev
There's absolutely no way you can run full-fledged WPF app on Mac. I'm not even sure if this is possible in Parallels. The best thing you can do is to use Silverlight, which was previously named "WPF/E" and does run on Macintosh.
您绝对无法在 Mac 上运行成熟的 WPF 应用程序。我什至不确定这在 Parallels 中是否可行。您能做的最好的事情是使用 Silverlight,它以前被命名为“WPF/E”并且可以在 Macintosh 上运行。
回答by Dmitri Nesteruk
It cannot be done. But since your UI is in WPF, what you could do is transform XAML into something else - like GTK#for example. Of course, if you're like me and use lots of .NET 3.5 functionality, that won't help you much.
这是不可能的。但是由于您的 UI 在 WPF 中,您可以做的是将 XAML 转换为其他内容 - 例如GTK#。当然,如果您像我一样使用大量 .NET 3.5 功能,那对您没有多大帮助。
One more reason to keep your UI in plain, simplistic XML to start with.
开始时将 UI 保持在简单、简单的 XML 中的另一个原因。
回答by Rick
You want a new feature (support a entire different platform) and you wish to put no effort in it. Sorry, most of the time that will not work.
你想要一个新功能(支持一个完全不同的平台)并且你不希望在它上面付出任何努力。抱歉,大多数情况下这是行不通的。
Besides the most basic (native) .NET stuff with mono, I do not think you can run a WPF application natively on MacOSX.
除了最基本的(本机).NET 与单声道的东西,我认为您不能在 MacOSX 上本机运行 WPF 应用程序。
If you think you can make more money by gaining Mac users. You might consider using other presentation methods. Due to your current 'investment' I'd say try Silverlight (yes, I read your rant about not doing so). Another option could be Adobe AIR / Flex.
如果你认为你可以通过获得 Mac 用户来赚更多的钱。您可以考虑使用其他演示方法。由于您目前的“投资”,我会说尝试 Silverlight(是的,我读过您关于不这样做的咆哮)。另一种选择可能是 Adobe AIR / Flex。
If you port your application this way. You can maintain a single codebase.. one that runs on both platforms.
如果您以这种方式移植应用程序。您可以维护一个单一的代码库。一个在两个平台上运行的代码库。
If you wish to spend more time on new features in your current codebase: ignore the Mac users.
如果您希望将更多时间花在当前代码库中的新功能上:忽略 Mac 用户。
回答by Iain M Norman
We were in a similar situation. We had a working Windows project and wanted a Mac version.
我们处于类似的情况。我们有一个可以运行的 Windows 项目,并且想要一个 Mac 版本。
Our product was in two parts, one a .Net application, the other a Director projector app.
我们的产品分为两部分,一个是 .Net 应用程序,另一个是 Director 投影仪应用程序。
The Director app should be easy right, cross platform and all? Well nope, it rarely is that easy, we ended up with two versions of the Director source file.
Director 应用程序应该很简单吧,跨平台等等?嗯,不,很少有这么容易的,我们最终得到了两个版本的 Director 源文件。
Getting the .Net app running required using Mono for the underlying engine, which worked well for us as we were only number crunching byte arrays really. The UI on the otherhand we had to rewrite in Cocoa. It cost us nearly as much as making the Windows version did, as we also had to learn all the Mac stuff as we went.
运行 .Net 应用程序需要使用 Mono 作为底层引擎,这对我们来说效果很好,因为我们实际上只是对字节数组进行数字运算。另一方面,我们不得不用 Cocoa 重写 UI。我们的成本几乎与制作 Windows 版本一样多,因为我们还必须边走边学所有 Mac 的东西。
Since then we've only updated the Windows version.
从那时起,我们只更新了 Windows 版本。
回答by Iain M Norman
We had a similar issue. We wrote a Mac version in Silverlight 3 (which supports quite alot of WPF .NET stuff). It was sandboxed but if this isn't a problem, you can do some nice stuff. Our codebase is now on WPF and Silverlight 3 and is the same, when we compile it produces the SL3 and Desktop apps.
我们有一个类似的问题。我们在 Silverlight 3 中编写了一个 Mac 版本(它支持相当多的 WPF .NET 内容)。它是沙盒的,但如果这不是问题,你可以做一些不错的事情。我们的代码库现在在 WPF 和 Silverlight 3 上并且是相同的,当我们编译它时会生成 SL3 和桌面应用程序。
回答by VOX
Actually, there's a CrossOver for you. Other people who answer view from programmer's point. IF I were you, I'll install CrossOver then install .NET 3.5 inside CrossOver and happily run the WPF software.
实际上,有一个 CrossOver 适合您。从程序员的角度回答观点的其他人。如果我是你,我会安装 CrossOver,然后在 CrossOver 中安装 .NET 3.5 并愉快地运行 WPF 软件。
http://www.codeweavers.com/products/cxmac/
http://www.codeweavers.com/products/cxmac/
or if you prefer a free (but more difficult) solution, try wine.
或者,如果您更喜欢免费(但更难)的解决方案,请尝试葡萄酒。
回答by Kelly
You can use Parallels. I have our office software written in C# and WPF and people use it on Mac under Parallels all the time.
您可以使用平行线。我有我们用 C# 和 WPF 编写的办公软件,人们一直在 Parallels 下在 Mac 上使用它。
As a further note, Parallels lets you run Windows Applications side by side with Mac OSX applications, visible in their own window on the Mac desktop. It also allows copy and paste and drag and drop between Mac and Windows apps.
进一步说明,Parallels 允许您并排运行 Windows 应用程序和 Mac OSX 应用程序,在 Mac 桌面上的它们自己的窗口中可见。它还允许在 Mac 和 Windows 应用程序之间复制、粘贴和拖放。
回答by Ivaylo Milanov
You can try Nevron Open Vision. It integrates in WPF,WinForms,Silverlight and MonoMac, Xamarin.Mac projects. This is not like running a WPF application on the Mac, but will rather require you to recode your application on the NOV platform. However once you do that your application (or modules) will run on all these platforms from a single code base. A nice example of this approach working is Nevron Writer (part of Nevron Office). It runs on Windows, Silverlight and Mac from a 100% single code base.
您可以尝试 Nevron Open Vision。它集成在 WPF、WinForms、Silverlight 和 MonoMac、Xamarin.Mac 项目中。这不像在 Mac 上运行 WPF 应用程序,而是需要您在 NOV 平台上重新编码您的应用程序。但是,一旦您这样做了,您的应用程序(或模块)将通过一个代码库在所有这些平台上运行。这种方法工作的一个很好的例子是 Nevron Writer(Nevron Office 的一部分)。它从 100% 的单一代码库运行在 Windows、Silverlight 和 Mac 上。
[Disclosure: I Work for Nevron]
[披露:我为 Nevron 工作]
回答by adabru
Another commercial solution is NoesisGUI (free for <100K gross annual revenue). It is a cross platform UI framework based on WPF/XAML. There is a guide for migration from WPF.
另一个商业解决方案是 NoesisGUI(年收入 <10 万美元免费)。它是一个基于 WPF/XAML 的跨平台 UI 框架。有一个从 WPF 迁移的指南。