Newtonsoft.Json icon indicating copy to clipboard operation
Newtonsoft.Json copied to clipboard

Cannot create and populate list type System.Data.SqlClient.SqlErrorCollection. Path '$values'

Open Danthar opened this issue 3 years ago • 6 comments

We have been having troubles with deserializing SqlExceptions using newtonsoft.net Version 11.0.2 On .Net 4.6.2 (Full) We didn't have these issues before when we where on an earlier version of newtonsoft. (10.x)

I have been searching around for how to fix this. But all i can find are solutions in which you decorate the offending property with an attribute. Which obviously is not a option here. Upgrading our .Net version is an option, but is non trivial for us. So im trying to find out if i have other options. Upgrading my TestCase to .net 4.8 also did not help. Neither does upgrading to newtonsoft 12.x

I believe this to be a Bug in Newtonsoft since version 11.x

Also have a SO question running. https://stackoverflow.com/questions/64308864/cannot-create-and-populate-list-type-system-data-sqlclient-sqlerrorcollection-p

Expected behavior.

Deserializing an System.Data.SqlClient.SqlException from the .net SDK (not .net core) should work.

Actual behavior;

image

Danthar avatar Oct 15 '20 13:10 Danthar

For convenience here is a gist with a reproduction case. https://gist.github.com/Danthar/536330ea6ec94874b16a2880769f936a

Danthar avatar Oct 15 '20 15:10 Danthar

So i added a TestCase PR, illustrating the issue. I would not mind submitting a PR to fix the issue. But i wouldn't know where to look.

Danthar avatar Oct 21 '20 09:10 Danthar

@JamesNK Anyhing i can do help facilitate to get some eyeballs on this issue?

Danthar avatar Oct 27 '20 15:10 Danthar

It only implements ICollection, which doesn't have an Add method, and there is no constructor for specifying values. There is no way to deserialize this type.

JamesNK avatar Oct 27 '20 17:10 JamesNK

And yet. It worked in older versions of json.net.

Op di 27 okt. 2020 18:57 schreef James Newton-King <[email protected]

:

It only implements ICollection, which doesn't have an Add method, and there is no constructor for specifying values. There is no way to deserialize this type.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JamesNK/Newtonsoft.Json/issues/2406#issuecomment-717420056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHQ3FY7I6QU7X3EWCXWYYDSM4CZXANCNFSM4SR7DB7Q .

Danthar avatar Oct 27 '20 18:10 Danthar

@JamesNK Is there anyway i can work around this perhaps? I don't know which change between 10.x and 11.x caused this issue. But is there perhaps a way i can have it handle the SqlException type differently? By for example, having it ignore the SqlErrorCollection ?

Danthar avatar Oct 28 '20 07:10 Danthar