Azure service fabric 使用服务结构远程处理捕获自定义异常

Azure service fabric 使用服务结构远程处理捕获自定义异常,azure-service-fabric,Azure Service Fabric,以下文档详细介绍了服务结构远程处理中的异常处理(我使用V2): 它有以下一段: 服务API引发的所有远程异常都将发送回 客户端为AggregateException。RemoteExceptions应该是DataContract 可序列化;如果不是,代理API将抛出ServiceException 其中包含序列化错误 在服务之间共享的.NET核心类库中,我做了以下例外: [DataContract] public class DuplicateEntityException : Excepti

以下文档详细介绍了服务结构远程处理中的异常处理(我使用V2):

它有以下一段:

服务API引发的所有远程异常都将发送回 客户端为AggregateException。RemoteExceptions应该是DataContract 可序列化;如果不是,代理API将抛出ServiceException 其中包含序列化错误

在服务之间共享的.NET核心类库中,我做了以下例外:

[DataContract]
public class DuplicateEntityException : Exception
{
    public DuplicateEntityException(string message = "Duplicate entity.") : base(message) { }
}
在调用的服务中引发异常后,我收到以下消息:

System.AggregateException: One or more errors occurred. (The exception DuplicateEntityException was unhandled on the service and could not be serialized for transferring to the client.
如果我只是抛出
异常
,它将正确序列化

如果能帮助我将异常类DataContract序列化,我将不胜感激。

我所要做的就是:

[Serializable()]
public class DuplicateEntityException : Exception, ISerializable
{
    public DuplicateEntityException(string message = "Duplicate entity.") : base(message) { }

    public DuplicateEntityException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}

这对我不起作用,还有其他细节遗漏吗?我仍然会遇到序列化异常