gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:55:31 25 4
gpt4 key购买 nike

我们的应用程序在 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 最终会出现在/bin/Linux 项目的发布目录(与主应用程序的 .exe 相同的目录)。

关于.net - Ubuntu 上 Newtonsoft.Json.Utilities.ConvertUtils 的类型初始值设定项抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28968447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com