Service Fabric 远程处理异常 -> 从 v1 升级到 v2

Service Fabric Remoting Exception -> upgrade from v1 to v2

我们有一个应用程序已经 运行 在 Service Fabric 上使用带有无状态服务的远程处理一段时间了。升级到 Remoting v2 后,某些方法失败并出现以下错误:

System.InvalidOperationException: 'Type 'System.String[]' cannot be added to list of known types since
 another type 'System.Collections.Generic.IEnumerable`1[System.String]' with the same data contract name 
'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfstring' is already present. If there
 are different collections of a particular type - for example, List<Test> and Test[], they cannot both be 
added as known types.  Consider specifying only one of these types for addition to the known types list.'

at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__23`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.ServiceFabric.Services.Remoting.V2.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__2.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsyncV2>d__21.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

我相信您 运行 正在 existing issue 使用远程处理 v2。 V2 需要 Remoting Api 类型是具体类型。

  • 不要在合同中使用 IEnumerable<string>string[]
  • 或提供 custom 实现 IServiceRemotingMessageSerializationProvider