4

インターネットで見つけたこの例を使用して、VSCode で F# に Akka.NET を使用しようとしています。

コード

// 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ライブラリが自動的にファイルに追加されました。これはコマンドの出力です

コマンド出力

どんな助けでも大歓迎です。ありがとうございました!

4

1 に答える 1