Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataContractJsonSerializer failing in Microsoft.NetCore.UniversalWindowsPlatform 5.2.2 #17943

Closed
kpanwar opened this issue Jul 27, 2016 · 3 comments · Fixed by dotnet/corefx#10537
Assignees
Milestone

Comments

@kpanwar
Copy link

kpanwar commented Jul 27, 2016

Our library is failing to deserialize blob of data when using Microsoft.NetCore.UniversalWindowsPlatform 5.2.2 in Visual Studio 2015. The deserialization works as expected for 5.1.0 and 5.0.0.

No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at System.Runtime.Serialization.XmlFormatReaderGenerator.UnsafeGetUninitializedObject(Type type)
at ReadAuthenticationResultFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadJsonValue(DataContract contract, XmlReaderDelegator reader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
at ReadAuthenticationResultExFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadJsonValue(DataContract contract, XmlReaderDelegator reader, XmlObjectSerializerReadContextComplexJson context)
at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(XmlDictionaryReader reader)
at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(Stream stream)
at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResultEx.Deserialize(String serializedObject)
at Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache.Deserialize(Byte[] state)
at AdalCacheIssue.MainPage.d__1.MoveNext()

@shmao
Copy link
Contributor

shmao commented Jul 28, 2016

Thanks for opening the issue, @kpanwar. Can you please share a repro app with us? Thanks!

@kpanwar
Copy link
Author

kpanwar commented Jul 30, 2016

@shmao - I sent you the app link

@shmao
Copy link
Contributor

shmao commented Aug 3, 2016

Thanks for sharing the repro app, Kanishk. I was able to repro the issue on my box. It’s caused by a bug in the de-serialization code. The bug caused that types which are marked with [DataContract] but have non-public default constructor cannot be de-serialized.

We will fix the bug. In the meantime, if you want to use Microsoft.NetCore.UniversalWindowsPlatform 5.2.2 and hit the issue, a workaround is to use the previous release of the serialization packages by adding the following dependencies in project.json,

    "System.Runtime.Serialization.Json": "4.0.1",
    "System.Runtime.Serialization.Primitives": "4.1.0",
    "System.Runtime.Serialization.Xml": "4.1.0",
    "System.Private.DataContractSerialization": "4.1.0"

SedarG referenced this issue in dotnet/corefx Jan 4, 2017
…t to build the two libs that we need to service for UWP (#14526)

* Fix a Bug with Serializing Types with Non-Public Default Ctor.

Fix #10374

* Adding System.Private.DataContractSerialization and System.Linq.Expressions to
packages.builds

* Follow-up changes to servicing S.Private.DataContractSerialization:
- Updating the versions of assemblies and packages for
System.Private.DataContractSerialization, System.Runtime.Serialization.Json,
System.Runtime.Serialization.Xml for the servicing event.
- Updating packages.builds to produce S.R.S.Json and S.R.S.Xml in additon
so S.P.DCS since those are the 'public' libs that expose the changes in S.P.DCS.
- There is an issue with servicing System.Linq.Expressions. I'm excluding it
  from packages.builds until I find a solution to the issue

* Adding netcore50 configurations to System.Linq.Expressions again in order
to ship rd.xml update.

* Review feedback changes; setting S.Linq.Expressions version to 4.1.1 instead of 4.3.1, and rolling back ref assembly version update of S.R.Serialization.Xml
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 1.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants