【问题标题】:What is wrong with this Akka.NET code?这个 Akka.NET 代码有什么问题?
【发布时间】:2017-08-27 15:43:07
【问题描述】:

我花了一些时间搜索 Akka.NET F# API。找不到它,即使有很好的 C# 文档。我找到了下面的代码,日期为 2017 年 3 月,看起来不错,但不幸的是,当我尝试运行它时会产生异常。

两个问题:

1) 下面的代码有什么问题?

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

观察:我尝试了其他几个我在网上找到的 F# Akka.NET sn-ps,它们都产生了异常。

代码的网址是:

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

【问题讨论】:

    标签: f# akka akka.net


    【解决方案1】:

    WatchWith 方法已在 Akka.NET v1.3 中引入,而您正在使用 Akka.FSharp v1.2.3。您需要将 Akka 依赖项降级回 1.2.3(此时 Akka.FSharp 在 v1.3 中尚不可用)。

    【讨论】:

    • 成功了!您是否有一个 URL,我可以在其中获得有关 Akka.FSharp API 的更多信息?有一个链接 getakka.net/docs/FSharp%20API> 但如果您单击它,您会收到以下消息:The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
    • Akka.FSharp API 本质上是一个文件,本身没有文档。还有一个替代 API (github.com/Horusiath/Akkling),它附有 github wiki 页面。但是,该 API 更加流畅,并且可能会随着时间而改变。
    • 谢谢@horusiath。在 FSharp API 方面,您提供了很多帮助。
    猜你喜欢
    • 2012-08-07
    • 2014-08-29
    • 2013-06-05
    • 2014-06-04
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多