Access LinqBridge from dll JSON.NET

I am using JSON.NET which has LinqBridge .dll. LinqBridge allows you to access Linq from .NET 2. If I try to use Linq, even after importing System.Linq , I get the following error:

 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 

If I try to enable LinqBridge, since JSON.NET already includes it, I get this warning. In addition, I included the same component twice, which is inefficient:

 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 

If I look at Newtonsoft.Json.Net20 in the Object Browser, I see that System.Linq seems to be empty, even after I selected Show hidden types and methods .

Is it possible to access Linq from a JSON.NET dll or to suppress error messages?

+4
source share
1 answer

The static static class that provides LINQ query operators in the LINQBridge assembly is still displayed in the System.Linq namespace.

You still need to have a using directive for System.Linq, as indicated in the first error message.

Update:

It turns out that the LINQBridge assembly, combined with Newtonsoft.Json.Net20.dll, was "internalized", which I did not notice at the beginning. This means that your code cannot reference the Enumerable type, which the compiler must "implement the query template". Therefore, you need to reference the LINQBridge assembly yourself, but then you get a warning about duplicate definitions, as you said.

You can turn off the warning about a repeating class by going to the "Assembly" tab of the properties of your project and enter "1685" in the "Suppress warnings:" field.

But it would be best to create your own version of JSON.net from a source without merging into LINQBridge.

+6
source

All Articles