C # VS2017 IStringable Unreferenced Exception using Windows.Data.Json

So, I'm going to jump straight.

I use Windows.Data.Jsonto convert and use some JSON from a web service. I know about Newtonsoft.Json.Net, and some others, etc., And yes, I specifically try to use Windows.Data.Jsonfor companies and causes of addiction.

The application has 3 main parts / components.

  • UWP Win 10 Application - Main Application
  • MVC Web Project - Web Services for the Application
  • Portable class library - for common classes between both

The problem is that when I use JsonObjectMVC in a web project or in PCL, I get an error:

The type "IStringable" is defined in an assembly that is not referenced. You must add a reference to the assembly "Windows.Foundation.FoundationContract, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = null, ContentType = WindowsRuntime".

This error appears wherever I use JsonObject, but NOT in the UWP application project.

eg.

//Convert string to json object
var apiJsonObj = JsonObject.Parse(jsonString);

and

cc.Type = apiJsonObj["TYPE"].ToString();

I searched the Internet and did not find anything useful in Windows.Data.Json, and not IStringable, except for this: https://docs.microsoft.com/en-us/uwp/api/windows.foundation.istringable

My project does not have the Windows.Foundation.FoundationContract file specified in the Add Links dialog box, and I cannot find any links to it in the UWP application that I use, and no other information that was used.

UWP - MVC JsonObject. UWP . - MVC .

, - Windows.Data.Json, , , ?

, , Json.Net ..

+4
1

, JsonObject, UWP.

Windows.Foundation.FoundationContract . . , pick winmd, .

C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\2.0.0.0\Windows.Foundation.FoundationContract.winmd

Json.NET , json. Json.NET, .

+1

Source: https://habr.com/ru/post/1685742/


All Articles