我正尝试使用F#创建一个可移植的库,以用于Windows应用商店应用。我创建了一个类的fs文件:Windows应用商店应用和F#
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
}
我在Windows Store应用程序中引用此库并没有问题。但问题是,我不能访问FunctionalRT
模块,也不能访问WebHelper
类。当我编写using FunctionalRT
或尝试使用FunctionalRT.WebHelper.FunctionalRT
时,编译器抱怨它不知道它。可能是什么问题?
编辑: 几个buidls后,并清除我得到
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
编辑:
添加引用到C:\Program Files (x86)\MSBuild\..\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\.NETPortable\FSharp.Core.dll
解决上面的错误消息,但还有另外一个
Cannot await 'Microsoft.FSharp.Control.FSharpAsync<string>'
你确定你所有的引用(包括.Net和第三方)都是WinRT兼容的吗? –
只有2个项目:Windows 8应用程序(App3)和F#可移植库(FunctionalRT与目标框架:用于Windows应用商店应用的.NET,.NET Framework 4.5,Silverlight 5)和App3有关于FunctionalRT的引用 –
我相信错误消息说C#项目也应该引用FSharp.Core(当然是WinRT版本)。我假设现在只有F#项目引用了FSharp.Core?如果我是正确的,那么在编写常规C#-F#应用程序时也会出现此错误。 –