BC30456 ‘ContainsKey’ is not a member of ‘JObject’

I’m taking-over maintenance of a project. We got the source code (I think) but parts of it don’t seem to compile nicely right now. The code seems a little rusty in places (eg. dotnet 4.0).

Right now I’m getting an error saying ‘ContainsKey’ is not a member of ‘JObject’. It is referring to a Newtonsoft.Json function (being called from my program). It is strange, because the obj browser confirms that it is missing. However, all of the docs that I can find, say it should be there. Goog, Bing and Stackover didn’t seem to find any info about this error message. How is that possible? Am I the only person who has ever seen this error?! Apparently, yes.

Something about this sounds really familiar. Like I’ve seen it before, several times (not just in this project). I just couldn’t remember what caused it, or how to fix it.

I eventually discovered the cause of this problem: the ‘ContainsKey’ property was added to Newtonsoft Json in version 11. My (old) project is referring to version 9.0.1 and the nuget packages.config for the project is pulling version 7.0.1. After looking around, I found a bin folder on a server. It had Newtonsoft.Json version 11.0.2, which is why the project would run from the server, but the code wouldn’t compile on my machine.

TLDR: You will get this error if you have Newtonsoft.Json which pre-dates 11.0.1. Upgrade to 11.0.1 (or newer) and this error goes-away. Right-click your project, “Manage Packages” or just edit your packages.config and “rebuild solution”.

About Tim Golisch

I'm a geek. I do geeky things.
This entry was posted in Errors. Bookmark the permalink.

Leave a comment