error CS0246 with Newtonsoft when upgrading Unity

Hello - I just upgraded Unity from 2021.2.8 to 2021.2.13 and was put into safe mode because of the error:

error CS0246: The type or namespace name ‘Newtonsoft’ could not be found (are you missing a using directive or an assembly reference?)

When I reverted to the old install, which had been working fine, the problem persisted. I’ve seen elsewhere that people have advised finding the Newtonsoft dll and putting it in Assets/Plugins. Where do I find this dll, and is this a sustainable approach going forward or will it create a mess when I do further install upgrades? Thanks!

1 Like

~~You can add it from the Asset Store/package manager: https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347~~
Alternatively get it from GitHub and follow the instructions here:
~~GitHub - applejag/Newtonsoft.Json-for-Unity: Newtonsoft.Json (Json.NET) 10.0.3, 11.0.2, 12.0.3, & 13.0.1 for Unity IL2CPP builds, available via Unity Package Manager

Edit: see my post below for updated instructions.

2 Likes

@PraetorBlue - thanks for your help! I didn’t originally import Newtonsoft as an asset (or at least I don’t recall doing so). Is there a reason it no longer works natively in the editor?

1 Like

Depending on what packages you are using, some of them transitively include Newtonsoft Json (I don’t know which off the top of my head) so you might have gotten it through some random package that either you removed or the new version of the package no longer includes it.

@PraetorBlue - Ah, I see. Yes, it was probably bundled with my SimpleSQL asset, then. Thanks for your help!

Just an update to this thread, the package is now officially maintained in the Unity Registry in UPM, and installation instructions can be found here:

4 Likes

very nice thanks!

1 Like

You just saved my life. I was going to go curl up in a ball and cry in a corner from not knowing what the fuck happened from upgrading my project’s Unity version and getting these errors.

1 Like