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>'
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With