In the Build 2011 keynote and demos, they were always talking about C++, C#, Visual Basic and JavaScript. Can't I build Metro style Apps with F#? Or is it safe to say that if it works with C#, then it works with F# as well?
6 Answers
Or is it eligible to say if it works with C# then it works with F# as well?
Yes, that's how it is supposed to work. In addition to javascript and C/C++, any CLS compliant language that runs on top of the CLR will have access to the WinRT API.
Unfortunately in the VS 2011 Express edition you don't get tooling support but I guess this will be added progressively or to other editions:

- 1,023,142
- 271
- 3,287
- 2,928
-
18It's not quite as easy. True, the runtime projection is entirely transparent to anything that compiles to IL, but most compilers also need to load type information from assemblies at compile-time (for type checking). This means being able to read and parse .winmd files, which have a few extensions compared to vanilla CLI assemblies. Furthermore .winmd files describe WinRT types as is, without applying CLR projection rules - e.g. if you read them you see a type implementing `IIterable
` WinRT interface, but at runtime CLR will map it to `IEnumerable – Pavel Minaev Sep 17 '11 at 19:10`. So compiler support is needed.
I had the same question and created a blog post: Create a Metro App in F# (NOT)
There are a few issues:
- You cannot reference ordinary .NET dll’s (even in C#). They have to be have recompiled with a “reference” to the WinRT. Because of this you cannot reference the F# dll. I think this will be solved when F# 3.0 get released (source: Understanding F# slide from Don Syme at build).
- The ability from F# to create Metro apps. This has to be built by the F# team. This is an open question. This is the all-F# approach (In WPF it is today possible but not recommended).
- Tool support for creation Metro front-end projects. This will be not the case for the F# 3.0 release. (source: Understanding F# slide from Don Syme at build).

- 81
- 2
Using Visual Studio 11 Developer Preview (Full, not Express), I was able to reference and run F# code from a C# Metro style application with the following caveats:
You will get a build warning saying that the project can't be referenced, even though Visual Studio will still allow you to add it.
You must remove all references to all DLL's in the F# project, including FSharp.Core.
By following these steps it is possible to run F# code from a C# Metro style application, but it is nearly impossible to write any useful code in F# without references to the core language libraries. Let's hope they update the libraries to be WinRT compatible soon.

- 477
- 4
- 9
I ported my stock chart library for .NET3.5-4.0 to Portable library,it works quite well on Metro with C# Metro application and some my Metro UI bridge. I'm convinced that I can use F# to make Metro application in many parts.

- 171
- 1
- 1
- 11
The question has been answered here: Windows 8 and F# Although you cannot create and design Metro apps directly in F#, you can still create so called Portable library in F# with all Models and ViewModels and use it in another Metro projects. It's not ideal, but it works.

- 1
- 1

- 10,600
- 3
- 36
- 66