以下行:
let system = System.create "MyActorSystem" <| Configuration.load ()
...在 F# 交互窗口中生成以下输出:
Binding session to 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll'...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Newtonsoft.Json.Converters.DiscriminatedUnionConverter' from assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
at Akka.Serialization.NewtonSoftJsonSerializer..ctor(ExtendedActorSystem system)
--- End of inner exception stack trace ---
在我的项目引用中,Newtonsoft.Json 指向 .\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll。我读到我需要 Akka.NET 的 Newtonsoft.Json 版本 7 或更高版本,所以我不确定为什么我在 FSI 输出中看到版本 4.5 的绑定(bind);这是一个我应该忽略的错误相关性吗?
我认为可能正在加载库文件的另一个副本,因此在 C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\FsiAnyCPU.exe.config
中,我补充道:
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.1.0" />
...但后来我得到 error FS0192: internal error: convMethodRef: could not bind to method
在 FSI 中。
我尝试查看融合日志; Newtonsoft.Json 库的绑定(bind)成功,因此没有什么可疑的事情发生。
还有人遇到这个问题吗?
编辑:好的,所以我在融合日志中发现了 Newtonsoft.Json.dll 的另一个副本,位于 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\
,正在拦截绑定(bind)。如何在不简单地从 Blend 文件夹中删除库文件的情况下防止这种情况发生?
最佳答案
我认为你的问题是你没有从包文件夹中加载 Json.NET:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll
写在脚本的顶部
#I __SOURCE_DIRECTORY__
这将在探测路径上添加源目录。 您的引用应该正确解析。
关于f# - F# Akka.NET 中的 System.create 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40644519/