Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Store Apps and F#

I am trying to create a portable library using F# to use with Windows Store apps. I created one fs file with one class:

module FunctionalRT

open System.Net
open System.IO

type WebHelper =

    static member DownloadStringAsync (url:string) = async {
        let req = HttpWebRequest.Create(url)
        use! resp = req.AsyncGetResponse()
        use stream = resp.GetResponseStream()
        let reader = new StreamReader(stream) 
        let s = reader.ReadToEnd()
        return s
    }

I referenced this library in my Windows Store app with no problems. But the problem is, I cannot access the FunctionalRT module neither the WebHelper class. When I write using FunctionalRT or try to use FunctionalRT.WebHelper.FunctionalRT, the compiler complains it does not know it. What may be the problem?

EDIT: After a few buidls and cleans I get

The type 'Microsoft.FSharp.Control.FSharpAsync`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'FSharp.Core, Version=2.3.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.  C:\Users\Igor\Documents\Visual Studio 2012\Projects\App3\App3\GroupedItemsPage.xaml.cs  46  13  App3

EDIT:

Adding a reference to C:\Program Files (x86)\MSBuild\..\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\.NETPortable\FSharp.Core.dll solved the above error message, but there is another one

Cannot await 'Microsoft.FSharp.Control.FSharpAsync<string>'
like image 458
Igor Kulman Avatar asked Oct 25 '12 07:10

Igor Kulman


People also ask

What are Windows Store apps called?

Universal Windows Platform (UWP) apps (formerly Windows Store apps and Metro-style apps) are applications that can be used across all compatible Microsoft Windows devices, including personal computers (PCs), tablets, smartphones, Xbox One, Microsoft HoloLens, and Internet of Things.

Where can I find Windows Store apps?

Programs and apps downloaded from the Microsoft Store are installed in the following path by default: C:/Program Files/WindowsApps (Hidden items). To check hidden items, open This PC, click View and select Hidden items.

What is the difference between Windows Store and Microsoft Store?

The Microsoft Store – formerly called the Windows Store -- is an online marketplace for consumers to buy and download a variety of items. The store enables users to purchase hardware such as PCs, Surface products and Xbox consoles, or download software and digital content, including apps, games, movies or TV shows.

Are Windows Store apps free?

However, many people don't realize that many apps in the store can help you stay productive, entertained, and informed. Best of all, all of those apps are absolutely free. The following are 10 of the best free Microsoft apps you'll find in the Microsoft Store.


1 Answers

You have to reference this library in your Windows Store app to make it work:

C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime.NETPortable\FSharp.Core.dll

And regarding that FSharpAsync class, see this thread:
Referencing Asynchronous F# datatype from C#

You could use static method of the FSharpAsync type for awaiting the returned object.

like image 182
Martin Suchan Avatar answered Sep 28 '22 01:09

Martin Suchan