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

标签 visual-studio f# .net-core visual-studio-2017

我在 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/

    相关文章:

    c# - 在 Azure Functions 中,如何在输出绑定(bind)中使用路由参数

    asp.net-core - .net core 添加 Web 引用

    c# - 将 ELMAH 日志 ID 传递到 ASP.NET 中的自定义错误页面时出现问题

    c++ - ICU 无法解析的外部符号

    wpf - 资源字典的 Visual Studio xaml 编辑器

    f# - 有没有办法嵌套调用 F# 事件模式?

    visual-studio - 无法设置下一个语句。下一条此时无法更改

    asp.net-core - 为什么 Giraffe/AspNetCore + SignalR 依赖注入(inject)无法解析 MailboxProcessor 单例?

    scala - 如何使私有(private)成员对象封装?

    c# - RestSharp 忽略 .NET Core 上的系统代理(例如 Fiddler)