gpt4 book ai didi

f# - Windows 应用商店应用程序和 F#

转载 作者:行者123 更新时间:2023-12-04 17:52:57 24 4
gpt4 key购买 nike

我正在尝试使用 F# 创建一个可移植库以与 Windows 应用商店应用程序一起使用。我用一个类创建了一个 fs 文件:

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类(class)。当我写 using FunctionalRT或尝试使用 FunctionalRT.WebHelper.FunctionalRT ,编译器提示它不知道它。可能是什么问题?

编辑:
经过几次构建和清理后,我得到了
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>'

最佳答案

您必须在您的 Windows 应用商店应用程序中引用此库才能使其工作:

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



关于该 FSharpAsync 类,请参阅此线程:
Referencing Asynchronous F# datatype from C#

您可以使用 FSharpAsync 类型的静态方法来等待返回的对象。

关于f# - Windows 应用商店应用程序和 F#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13063792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com