How do I include 'System.Runtime.Serialization.Json' namespace in my VSCode project on Mac OS X?

2.5k views Asked by At

I was hoping to use System.Runtime.Serialization.Json in a simple Visual Studio Code console app on my Mac OS X but I am running into this compile error:

The type or namespace name 'Json' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)

Based on this post - Where is the System.Runtime.Serialization.Json namespace?, I added "System.ServiceModel.Web": "1.0.0" to my project.json file but that did not help. I added 1.0.0 since that's the only version I found in nuget - https://www.nuget.org/packages/System.ServiceModel.Web/

As an alternative, I tried using https://www.nuget.org/packages/Newtonsoft.Json/6.0.8 by adding the following in my project.json - "Newtonsoft.Json": "6.0.8" but then adding the reference of using Newtonsoft.Json; again gives a compile error of - The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

Ultimately I would like to derserialize a json stream from my VSCode console app, so hoping to get pointers on how that can be done?

1

There are 1 answers

0
Matt DeKrey On BEST ANSWER

System.Runtime.Serialization.Json is not going to get ported to .Net Core; you did the right thing by going to Newtonsoft.Json.

Unfortunately, you added it only to the dnxcore50 section; you need to add it to the framework-agnostic dependency section:

{
  "version": "1.0.0-*",
  "dependencies": {
    "System.ServiceModel.Web": "1.0.0",
    "Newtonsoft.Json": "6.0.8"
  },
  "commands": {
    "run": "run"
  },
  "frameworks": {
    "dnx451": {},
    "dnxcore50": {
      "dependencies": {
        "System.Console": "4.0.0-beta-*",
        "System.ServiceModel.Web": "1.0.0"
      }
    }
  }
}