gpt4 book ai didi

json.net - 从 JSON.NET dll 访问 LinqBridge

转载 作者:行者123 更新时间:2023-12-05 00:37:35 25 4
gpt4 key购买 nike

我正在使用 JSON.NET其中有 LinqBridge .dll 合并。LinqBridge 允许从 .NET 2 访问 Linq。如果我尝试使用 Linq,即使在导入后 System.Linq ,我收到以下错误:

Error   13  Could not find an implementation of the query pattern for source type 'int[]'.  'Where' not found.  Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?    C:\Users\chrisl\Desktop\SoftTokens\Windows Desktop Soft-Token\Program.cs    27  25  WindowsSoftToken

如果我尝试包含 LinqBridge,那么由于 JSON.NET 已经包含它,我会收到此警告。此外,我已经两次包含相同的组件,这是低效的:
Warning 2   The predefined type 'System.Action' is defined in multiple assemblies in the global alias; using definition from 'c:\Users\chrisl\Desktop\SoftTokens\Windows Desktop Soft-Token\libs\Newtonsoft.Json.Net20.dll' WindowsSoftToken

如果我浏览 Newtonsoft.Json.Net20在对象浏览器中,我看到 System.Linq 显示为空,即使我选择了 Show hidden types and methods .

是否可以从 JSON.NET dll 访问 Linq 或抑制错误消息?

最佳答案

在 LINQBridge 程序集中提供 LINQ 查询运算符的 Enumerable 静态类仍公开在 System.Linq 命名空间中。

您仍然需要按照第一条错误消息中的指示为 System.Linq 使用 using 指令。

更新:

事实证明,合并到 Newtonsoft.Json.Net20.dll 中的 LINQBridge 程序集已经“内部化”了,我一开始没有注意到。这意味着您的代码不能引用编译器“实现查询模式”所需的 Enumerable 类型。因此,您必须自己引用 LINQBridge 程序集,但随后您会收到有关重复定义的警告。

您可以通过转到项目属性的“构建”选项卡并在“抑制警告:”框中输入“1685”来禁用重复类警告。

但是可能更好的是从源代码构建您自己的 JSON.net 版本,而无需在 LINQBridge 中合并。

关于json.net - 从 JSON.NET dll 访问 LinqBridge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6645973/

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