Azure-docs: Newtonsoft.Json.JsonSerializationException

Created on 9 Jan 2019  Â·  14Comments  Â·  Source: MicrosoftDocs/azure-docs

I am using the exact code of yours but I have an exception
Error converting value "Microsoft.ServiceFabric.Services.Remoting.V2.ServiceRemotingResponseMessageBody, Microsoft.ServiceFabric.Services.Remoting" to type '*.Serialization.JsonBody'. Path '$type', line 1, position 133.
Inner Exception: Could not cast or convert from System.String to *
.Serialization.JsonBody.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 cxp in-progress product-question service-fabrisvc triaged

All 14 comments

Thanks for the feedback! We are currently investigating and will update you shortly.

@washraf can you point me to the point in the doc that you are referring to? This doc has multiple samples so not sure exactly which code you are referring to.

The Use custom serialization with a remoting wrapped message sample

@washraf thanks for that.

@aljo-microsoft @vturecek any suggestions?

Section is directly liked here: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting#use-custom-serialization-with-a-remoting-wrapped-message

@VipulM-MSFT for additional suggestions.

@washraf
Are you using remoting V2 stack by explicitly using V2 classes, or are you using assembly attribute?

I'd need more context, but the error provided seems to indicate its related to how you implemented: "ServiceRemotingDataContractSerializationProvider"

@washraf - can you provide the repro? Is it just following the steps in the documentation on some sample?

@suchiagicha - for investigation.

@VipulM-MSFT I have created this repo with an exact sample to my work and it have the same issue
https://github.com/washraf/Service-Fabric-core-custom-serializer

Thanks @washraf

@VipulM-MSFT @suchiagicha any further comment?

@washraf

@suchiagicha is looking into this further. She will update when she has more information.

@washraf just a quick update, we did find an issue in the Json serialization code. We are investigating and should have an update by end of the week.

@MicahMcKittrick-MSFT
Thanks but I have a post error issue which made me start searching for a custom serializer in the first place. I am sending a generic object among the result. Can you inform me on this as well.

@washraf
There is a known issue in json .net core serialization where Assembly loadWithPartialName will throw an Exception. Here is the issue detail
https://github.com/JamesNK/Newtonsoft.Json/issues/1808

If you try same sample in full framework, it should work.
For .net core workaround , Icreate CustomSerialization Binder , as mentioned here .
https://github.com/Microsoft/service-fabric/issues/202#issuecomment-416550191
This should work for you.

@suchiagicha
Thanks it worked.

I am running into the same issue. Using the code from here https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting to change Service Fabric to use JSON Serialization.

I too have the "UseWrappedMessage" set to true in my listener and in my client factory.
I also have the "CustomSerializationBinder.cs" mentioned in the Service Fabric thread that brought me to this issue. Service Fabric Issue on GitHub

This is the exception I am getting.

Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Type specified in JSON 'Microsoft.ServiceFabric.Services.Remoting.V2.ServiceRemotingResponseMessageBody, Microsoft.ServiceFabric.Services.Remoting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not compatible with 'CRT.Infrastructure.Common.Serialization.JsonBody, XYZ.Infrastructure.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Path '$type', line 1, position 133.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, String qualifiedTypeName)

Thanks for any help. This is frustrating - especially seeing that the issue has been going on since Aug 2018.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments

jamesgallagher-ie picture jamesgallagher-ie  Â·  3Comments