C# - 在 Service Fabric RPC 服务中获取任何类型的对象
C# - Getting object of any type in Service Fabric RPC Service
有一个 Service Fabric Rest (http) 服务公开了一个 POST 端点,该端点采用一个名为 Action 的协定,该协定具有一个字典。该服务接受 Action 并调用 Service Fabric RPC 服务来执行创建操作操作。
public class Action{
public Dictionary<string, object> actions {get; set;}
}
当为对象类型传递原始类型(数组、字典)以外的任何类型时,Rest 端点正确反序列化 json,但在尝试使用以下调用 RPC 服务时失败错误信息
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.
我们也尝试过使用动态和 ExpandoObject 来代替对象。这似乎也没有帮助。
有人遇到过将对象或动态类型传递给 RPC 服务的问题吗?
Service remoting works with the DataContractSerializer。您在服务合同中使用的所有类型都必须可序列化。
类型 JToken
不是,因为它具有相同类型的属性。
有一个 Service Fabric Rest (http) 服务公开了一个 POST 端点,该端点采用一个名为 Action 的协定,该协定具有一个字典。该服务接受 Action 并调用 Service Fabric RPC 服务来执行创建操作操作。
public class Action{
public Dictionary<string, object> actions {get; set;}
}
当为对象类型传递原始类型(数组、字典)以外的任何类型时,Rest 端点正确反序列化 json,但在尝试使用以下调用 RPC 服务时失败错误信息
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.
我们也尝试过使用动态和 ExpandoObject 来代替对象。这似乎也没有帮助。
有人遇到过将对象或动态类型传递给 RPC 服务的问题吗?
Service remoting works with the DataContractSerializer。您在服务合同中使用的所有类型都必须可序列化。
类型 JToken
不是,因为它具有相同类型的属性。