是否可以使用F#开发Windows 8通用应用程序

是否可以使用F#开发Windows 8通用应用程序,f#,windows-8.1,F#,Windows 8.1,我想用F#开发windows 8.1通用应用程序。所以我创建了F#便携式图书馆。但不幸的是,我无法打开它上面的Windows.Storage命名空间 然后,我创建了C#Windows应用程序类库,在其中实现了所需的功能: public static async Task<string> ReadFileToString(string filename) { StorageFile file = await StorageFile.GetFileFromPathAs

我想用F#开发windows 8.1通用应用程序。所以我创建了F#便携式图书馆。但不幸的是,我无法打开它上面的Windows.Storage命名空间

然后,我创建了C#Windows应用程序类库,在其中实现了所需的功能:

 public static async Task<string> ReadFileToString(string filename)
 {
        StorageFile file = await StorageFile.GetFileFromPathAsync(filename);
        string fileContent =  "";
        fileContent = await FileIO.ReadTextAsync(file);

        return fileContent;
 }
公共静态异步任务ReadFileToString(字符串文件名)
{
StorageFile文件=等待StorageFile.GetFileFromPathAsync(文件名);
字符串fileContent=“”;
fileContent=await FileIO.ReadTextAsync(文件);
返回文件内容;
}
然后我想把我的F#Portable库中的引用添加到这个C#库中,但得到错误消息,即

“这是不可能的,因为该项目是为平台设计的 (.NETCore)与当前(.NETPortable)不同


可以使用F#开发windows 8通用应用程序吗?

以下是我找到的解决方案

  • 使用NuGet to F#portable library和Windows 8.1应用商店应用程序安装(!)
  • 在F#库中设置“复制到本地”=False(!)
以下是f#库的代码:

下面是C#Store应用程序代码:

private void按钮\u单击(对象发送者,路由目标)
{
MyClass cls=新的MyClass();
cls.Do(“uuu.ii”,“我的信息”);
}

如果你让你的C#项目成为一个可移植的库,那么它应该可以工作。与F#无关。可移植库无法引用针对特定平台的库。是的,但我不能在此库中使用Windows.Storage命名空间(和StorageFile)。因此,我希望能够阅读通用应用程序中用F#编写的文件,检查您用于创建F#库的配置文件。有不同类型的可移植库。如果我理解正确,我只有一个选项“.Net可移植子集(Net Framework 4.5,Windows 8)”。但看起来这是可能的。例如,我找到了Andy B在F#中使用StorageFile的代码(),我检查了两个配置文件(7和47)。他们都无法打开Windows。StorageFile这是否适用于Windows 10?
namespace PortableLibrary1

open PCLStorage

type MyClass() =
    member this.Do (filename : string) (text : string) = 
        let folder = FileSystem.Current.LocalStorage       
        async {
            let! result = Async.AwaitTask(folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting))
            result.WriteAllTextAsync(text) |> ignore        
        } |> Async.RunSynchronously