Ubuntu 上 Newtonsoft.Json.Utilities.ConvertUtils 的类型初始值设定项抛出异常

An exception was thrown by the type initializer for Newtonsoft.Json.Utilities.ConvertUtils on Ubuntu

我们的应用在 Windows 上使用 JSON.net 就好了。在 Linux 上(我们在 Ubuntu 中进行测试)我们得到一个异常:

    An exception was thrown by the type initializer for Newtonsoft.Json.Utilities.ConvertUtils
    20150310_11:51:37.404 ERROR  :    at Newtonsoft.Json.Serialization.DefaultContractResolver.IsJsonPrimitiveType(System.Type t)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(System.Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(System.Type type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(System.Type type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(Newtonsoft.Json.JsonReader reader, System.Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(Newtonsoft.Json.JsonReader reader, System.Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String value, Newtonsoft.Json.JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String value)

InnerException 是

Could not load file or assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.

在网上的其他地方,他们说我们可能需要安装 "libmono-system-numerics4.0-cil" 但 apt-get 显示已经安装并且是最新的。

我们正在使用 .NET 4.0(因为我们希望与 Windows XP 保持兼容,市场份额仍然很大)。

关于如何获得它的任何想法运行?

出于某种原因,它只是不想与安装在 Linux 上的版本配合并且永远无法加载它。

这是我所做的,最终导致它 运行:

  • 添加了对使用 JSON.net
  • 的项目的 System.Numerics 引用
  • 从有效的 Windows 发行版中获取 System.Numerics.dll(这可能是一个 .NET 程序集而不是 Mono)并将其添加到我的构建过程中,使得 System.Numerics.dll 最终位于 Linux 项目的 /bin/Release 目录中(与主应用程序的 .exe 目录相同)。