簡體   English   中英

這個Akka.NET代碼有什么問題?

[英]What is wrong with this Akka.NET code?

我花了一些時間搜索Akka.NET F#API。 找不到它,即使有很好的C#文檔。 我發現下面的代碼,日期為2017年3月,看起來不錯,但不幸的是,當我嘗試運行它時會生成異常。

兩個問題:

1)下面的代碼有什么問題?

2)是否有Akka.Net F#API的在線文檔,如果是,它在哪里?

觀察:我嘗試了在網上找到的其他幾個F#Akka.NET片段,所有這些片段都產生了異常。

代碼的URL是:

https://www.seventeencups.net/building-a-mud-with-f-sharp-and-akka-net-part-one/

這是我試圖運行的代碼:

open System
open Akka.Actor
open Akka.Configuration
open Akka.Remote
open Akka.FSharp

let system = System.create "system" (Configuration.defaultConfig())

type GreeterMsg =
    | Hello of string
    | Goodbye of string

let greeter = spawn system "greeter" <| fun mailbox ->
    let rec loop() = actor {
        let! msg = mailbox.Receive()

        match msg with
        | Hello name -> printf "Hello, %s!\n" name
        | Goodbye name -> printf "Goodbye, %s!\n" name

        return! loop()
    }
    loop()

異常消息包括以下內容:

System.TypeLoadException: Method 'WatchWith' in type '-ctor@270' from assembly 'Akka.FSharp, Version=1.2.3.41, Culture=neutral, PublicKeyToken=null' does not have an implementation

在Akka.NET v1.3中引入了WatchWith方法,而你正在使用Akka.FSharp v1.2.3。 您需要將Akka依賴關系降級回1.2.3(此時Akka.FSharp尚未在v1.3中提供)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM