gpt4 book ai didi

visual-studio - 如何在 Visual Studio 2017 中为 .Net core 2.1 应用程序引用 F# 交互中的 Dll?

转载 作者:行者123 更新时间:2023-12-04 19:27:12 25 4
gpt4 key购买 nike

我在 Windows 上的 Visual Studio 2017 中创建了一个 .Net core 2.1 F# 控制台应用程序。我会在 F# 交互窗口中尝试代码。但是,右键单击 Dependencies不会显示将引用发送到 F# 交互窗口的命令。展开 NuGet 树可以找到 DLL 文件名,但它们没有完整路径,因此我无法手动运行 #r ".../full path/Akka.FSharp.dll";; .

  • 在哪里可以找到 DLL 文件?
  • 是否可以添加 .Net 核心引用的 DLL?

  • 测试 .Net 核心应用程序的代码。
    open System
    open Akka.FSharp

    let system = System.create "MovieStreamingActorSystem" <| Configuration.load ()

    type ProcessorMessage = ProcessJob of int * int * string

    let processor (mailbox: Actor<ProcessorMessage>) =
    let rec loop () = actor {
    let! m = mailbox.Receive ()
    printfn "Message %A" m
    return! loop ()
    }
    loop ()

    [<EntryPoint>]
    let main argv =
    let processorRef = spawn system "processor" processor
    processorRef <! ProcessJob(1, 2, "3")
    0

    最佳答案

    您目前无法执行此操作,因为 F# Interactive 不支持 .net 核心。 🙃 然而,由于 API 表面几乎与 .net 4.7 相同,您可以直接引用它所需的包,只需直接获取任何需要的 dll 并使用 #r :

    #if INTERACTIVE
    #r "System.IO.Compression.FileSystem.dll"
    #endif

    例如,这将允许您通过从 .net 中提取压缩 dll 来使用一些用于 zip 存档的扩展方法。

    .net core dll 将打包在 publish 中文件夹,如果您决定创建一个独立于框架的包。无论 fsharp 交互需要什么完整的框架 dll,只需将它们直接下拉或拉到另一个项目即可。

    顺便说一句,如果你想知道 .net 核心 nuget 包在哪里被拉下来,它在: C:\Users\$USERNAME\.nuget\packages .如果支持,您应该会找到 net45 和 netstandard2 版本。

    更新 : 在 VS2019 预览版中,F# Interactive 是 dotnetcore,可以引用 dotnetstandard dll。

    关于visual-studio - 如何在 Visual Studio 2017 中为 .Net core 2.1 应用程序引用 F# 交互中的 Dll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52357761/

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