9

I know WPF libraries aren´t implemented by mono class library, however(as far as I know) the mono 2.6 runtime is fully compatible with the .NET 2.0/3.5 runtime, so if the WPF libraries only make PInvoke calls to windows api it is theoretically possible to run a wpf application on windows using the mono runtime. The reason for wanting that is deploying a wpf application as a standalone executable for windows. Has anyone tried something like that before? If so, what were the results?

Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69
  • 1
    Windows Vista and Windows 7 come out of the box with .NET 2.0 and 3.0. So if you want to avoid telling your customers that they need to install the .NET framework, simply targetting one of those versions might be a much simpler solution than going for a mono stand-alone app. – Wim Coenen Jun 03 '10 at 00:37

6 Answers6

5

In short... No

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

Mono will provide Moonlight support which, from what I understand, would also use a subset of XAML to create its UI (the same as Silverlight does) but there are legal complications involved. Such as, it's limited to non-microsoft and non-mac platforms.

If you want to find a list of open-source cross-platform alternatives to WPF/XAML I'm working to compile a list of viable alternatives.

Community
  • 1
  • 1
Evan Plaice
  • 13,944
  • 6
  • 76
  • 94
  • 1
    As I already said in the last two answers, I'm not asking if mono has an equivalent implementation of WPF libraries, I know it doesnt. What I asked is if someone tried running a wpf application on windows using the mono runtime, it doesnt matter if this application uses the managed libraries that ships from .NET or Mono, all I care to know is if the mono runtime(mono.dll) works well with wpf libraries; – Thiago Padilha Jun 11 '10 at 20:26
  • @Thiado "What I asked is if someone tried running a wpf application on windows using the mono runtime" The problem with that statement is, WPF cannot run using the mono runtime because the mono runtime doesn't support it. The question is the equivalent to asking "does winforms work well with mono." Plainly, mono does not and will not support WPF in any form now or in the future. Except maybe Silverlight/Moonlight in a limited fashion but I addressed that avenue. When I say 'Mono' I'm referring to the runtime and the library. – Evan Plaice Jun 11 '10 at 20:51
  • Evan, theres a diference between the Mono runtime and Mono BCL. Mono BCL does not have plans to add WPF libraries, However Mono runtime is an implementation of ECMA Common Language Infrastructure. Mono runtime and .NET runtime are both native programs that the main purpose is to execute(JIT compile) managed assemblies(System.dll,PresentationFramework.dll). Thats why Mono can run programs written for .NET and vice versa. Thats why I posted this question. Theoretically the Mono runtime can execute WPF libraries as well as .NET does(as long as it is on windows due to Directx dependencies). – Thiago Padilha Jun 11 '10 at 21:57
  • See for yourself: http://www.ecma-international.org/publications/standards/Standard.htm There is no note anywhere that WPF/XAML is an ECMA standard. Theoretically mono 'could' run WPF/XAML, but the first link in my answer is a clear indication that it won't because the mono development team is not willing to support it. In this case, mono (the organization) encompasses the runtime and the BCL. – Evan Plaice Jun 11 '10 at 22:52
  • Believe me, I've been searching everywhere for an indication that it could. Most of what I've found is controversy about MS not releasing a standard for XAML and MS forcefully including support for it in browsers without user's permission. A lot of people think XAML is a strategic move to try to overtake HTML on the web. – Evan Plaice Jun 11 '10 at 22:55
  • WPF/XAML is not an standard, but compiled WPF applications contain intermediate language code. XAML is compiled into BAML(which is certainly not understood by mono or the .net runtime) but the BAML processing is probably done by one of the managed WPF libraries(PresentationFramework.dll/PresentationCore.dll) if not my the unmanaged library(milcore.dll). So far, I have seen nothing that stops Mono from running wpf applications(if those managed WPF libs are avaliable in Mono's probe path). Since no one ever tried, I will test myself when I get the time. – Thiago Padilha Jun 11 '10 at 23:23
  • @Thiado de Arruda It's called patent protection. WPF was never submitted as an ECMA standard and will most likely never be. Microsoft want's their piece of the web and they're not willing to give it away for free. As for the rest of the .Net stuff, most of it including the CLI are all ECMA standards. The reason it'll never be used is a licensing not a technical issue. – Evan Plaice May 13 '11 at 22:30
  • 2
    What he is talking about is Using Microsoft's DLLs with mono, not mono's own implementation of WPF. So if I take PresentationFramework.dll from .NET and copy it to mono's gac, legal issues aside, will it work? – Ivan Sep 13 '11 at 07:28
  • I did give it a try, but no success :(, I documented my experience in an answer below.. – Ivan Oct 11 '11 at 07:20
3

Well I did give it a try with little success. I first checked with corflags if required dll-s are implemented in mixed mode (PresentationFramework, PresenationCore, WindowsBase, System.Xaml). They are all pure CIL implementations so that should work fine with mono. Next I installed mentioned DLLs into mono's GAC and tried running a very simple WPF application. This is what I got:

  • Assertion at mini-codegen.c:1186, condition `reginfo [sreg].born_in

    0' not met This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

So although in theory this should all work, WPF is probably way to complex to run out of the box on mono, it would be cool if there was a pure CIL implementation of WPF that was compatabile with both mono and .NET Framework.

Ivan
  • 1,735
  • 1
  • 17
  • 26
2

As much as I know, Mono does not support WPF.

Also, WPF uses graphics modules and interacts directly with the GPU. So I can't see how u can use WPF with no hidden pinvokes.

Amirshk
  • 8,170
  • 2
  • 35
  • 64
  • I think that means that mono base class library doesnt implement WPF libraries((presentationcore.dll,presentationframework.dll...). As far as I understand(http://en.wikipedia.org/wiki/Windows_Presentation_Foundation) WPF makes unmanaged calls(using PInvoke?) to milcore.dll which comunicates with DirectX. WPF libraries are not compatible with unix systems because of that dependency on directx, however I think its libraries can be executed my the mono runtime(which can run .net 3.5 managed libraries) IF the runtime is loaded on Windows. – Thiago Padilha Jun 02 '10 at 22:25
  • that may be possible, never tried mono outside the unix environment. – Amirshk Jun 02 '10 at 22:28
0

Sounds like you need to read about WPF architecture to better understand it.

http://msdn.microsoft.com/en-us/library/ms750441.aspx

Many pieces are missing in Mono and solely available in .NET. Therefore, your "theory" is not correct, and you cannot run WPF applications on Mono, even on Windows.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • What do you mean by 'pieces missing in Mono and solely avaliable in .NET'? Both 'PresentationCore.dll' and 'PresentationFramework.dll' are managed libraries, which makes them compatible with Mono's JIT. The only unmanaged piece of WPF is 'milcore.dll' which(to my knowledge) can be called from managed code either trough PInvoke or Internal CLR calls(both are suported by Mono's JIT). I have read the link you posted and it says nothing about a feature only avaliable to the .NET's CLR, pehaps you are willing to explain? – Thiago Padilha Jun 08 '10 at 17:37
0

At MIX 2010 Miguel de Icaza said in his session that Mono isn't going to support WPF. Anything tangentially related to WPF-like support is only to provide what is needed for Moonlight.

TodK
  • 1,079
  • 10
  • 17
0

Not fully, but..

You can use Moonlight 4 ( silverlight 4 ) in a desktop mode:-

https://github.com/inorton/MoonBase - MVVM helpers

https://github.com/inorton/XamlPreviewer - XamlPad clone

IanNorton
  • 7,145
  • 2
  • 25
  • 28