'Why can't I reference System.Runtime.Serialization.Json in C#
I want to use an API to get info from the interwebz. The API returns data in Json format.
- I'm running Microsoft Visual Studio C# 2010 Express addition.
- It appears that I have the .NET Framework 4 Client Profile set as my "Target framework" but I'm honestly not sure exactly what this means.
- This is a Windows Forms Application...
Not much code to show because I can't really get started without the appropriate using statement...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Net;
using System.Runtime.Serialization.Json;
I get this error:
The type or namespace name 'Json' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)
Am I missing a DLL file or something? Based on my hours of fruitlessly searching for solutions, I understand that the .NET 4.xx should already have the tools needed to parse up a Json formatted string?
Solution 1:[1]
you need to import System.Runtime.Serialization dll from reference
Solution 2:[2]
You need to add a reference to your project.
In the Solution Explorer right click references then add reference. You'll see a list of DLL's and you have to check the box next to the one you need for it to be added to the project. After you've done this you can successfully add the using statement.
Hope that helps!
Solution 3:[3]
The general process for serializing and deserializing JSON from C# is:
Add a reference to the System.Runtime.Serialization library.
Add using directives for System.Runtime.Serialization and System.Runtime.Serialization.Json.
Solution 4:[4]
Please change your Target framework from .NET Framework 4 Client Profile to .NET Framework 4
Solution 5:[5]
I know this is an old question, but I came across this in .NET 5.0 and the solution is to add using System.Text.Json to the top of your code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eanthmue |
| Solution 2 | eddie_cat |
| Solution 3 | Jawier |
| Solution 4 | Wasif Hossain |
| Solution 5 | ColorCodin |
