加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

从JSON.NET DLL访问LinqBridge

发布时间:2020-12-16 18:40:45 所属栏目:百科 来源:网络整理
导读:我正在使用 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.
我正在使用 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:UserschrislDesktopSoftTokensWindows Desktop Soft-TokenProgram.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:UserschrislDesktopSoftTokensWindows Desktop Soft-TokenlibsNewtonsoft.Json.Net20.dll' WindowsSoftToken

如果我在对象浏览器中浏览Newtonsoft.Json.Net20,我看到System.Linq显示为空,即使我选择了显示隐藏的类型和方法.

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

解决方法

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

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

更新:

事实证明,合并到Newtonsoft.Json.Net20.dll的LINQBridge程序集已经“内化”,我最初没有注意到.这意味着您的代码无法引用编译器“实现查询模式”所需的Enumerable类型.因此,您必须自己引用LINQBridge程序集,但是如您所述,您会收到有关重复定义的警告.

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

但更好的方法是从源代码构建自己的JSON.net版本而不在LINQBridge中合并.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读