简体   繁体   中英

C# - Getting object of any type in Service Fabric RPC Service

There is a Service Fabric Rest (http) Service that exposes a POST endpoint which takes a contract called Action that has a Dictionary. The service accepts the Action and calls an Service Fabric RPC service to perform the create action operation.

public class Action{
  public Dictionary<string, object> actions {get; set;}
}

When any type other than primitives (array, dictionary) are passed for the object type, the Rest endpoint deserializes the json properly, but fails at the place when trying to call the RPC Service with the following error message

Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

We have also tried using dynamic and ExpandoObject instead of object. That also doesn't seem to help.

Has any one faced this issue with passing object or dynamic types to RPC Services ?

Service remoting works with the DataContractSerializer . All types you use in the Service contract must be serializable by that. The type JToken is not, because it has properties of the same type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM