"Does not contain definition" error when trying to call a specific static method in Json.NET
I'm on the latest beta version of LINQPad 5 (v5.09.04) and I was trying to call the static method Newtonsoft.Json.JsonSerializer.CreateDefault() from the Json.NET NuGET package (9.0.1). I get an error that it does not contain a definition for CreateDefault.
So, I looked at the version being used.
I then dropped the assembly into ILSpy to verify that the method does exist.
I then tried another static method, Create(), which LINQPad doesn't complain about. I was confused at this point so I installed LINQPad 4 and pulled the same Json.NET nuget packages and it works fine. I compared the Json.NET assemblies and they are the same. In LINQPad 5 I next tried changing the supportedRuntime setting in the App.config to see if that had any effect, but it didn't.
I'm sure that I have missed something, but I just can't think of what it could be.
So, I looked at the version being used.
I then dropped the assembly into ILSpy to verify that the method does exist.
I then tried another static method, Create(), which LINQPad doesn't complain about. I was confused at this point so I installed LINQPad 4 and pulled the same Json.NET nuget packages and it works fine. I compared the Json.NET assemblies and they are the same. In LINQPad 5 I next tried changing the supportedRuntime setting in the App.config to see if that had any effect, but it didn't.
I'm sure that I have missed something, but I just can't think of what it could be.
Comments
I'm on a similar build and don't see that issue.
Run the following query:
typeof (JsonSerializer).Assembly.Location
It was referencing an old assembly in my Plugins directory. It looks like back in 2012 I had created a dll with my common extension methods which I abandoned after the 'My Extensions' feature came out and there was an old Newtonsoft dll in there.