我正在尝试使用我在互联网上找到的这个示例在 VSCode 中将 Akka.NET 用于 F#。
代码
// ActorSayHello.fsx
#time "on"
// #load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor
// Actors are one of Akka's concurrent models.
// An Actor is a like a thread instance with a mailbox.
// It can be created with system.ActorOf: use receive to get a message, and <! to send a message.
// This example is an EchoServer which can receive messages then print them.
let system = ActorSystem.Create("FSharp")
type EchoServer =
inherit Actor
override x.OnReceive message =
match message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
let echoServer = system.ActorOf(Props(typedefof<EchoServer>, Array.empty))
echoServer <! "F#!"
system.Shutdown()
但我收到了这个错误
ActorSayHello.fsx(6,6): error FS0039: The namespace or module 'Akka' is not defined.
我已经在 VScode 中配置了 ionide 插件,并且能够在没有 Akka.NET 的情况下运行 F#。我使用以下命令安装了 Akka.NET
dotnet add package Akka.FSharp --version 1.4.10
该库已自动添加到.fsproj
文件中。这是命令的输出
任何帮助将不胜感激。谢谢!