字典没有正确序列化。

我有WCF服务,我尝试从客户端向服务器发送“ 0”。我的WCF服务使用默认的BasicHttpBinding。 当我将字典发送到服务器时,不会引发任何错误。但是当我尝试循环通过我的字典时,它是空的。 奇怪的是
Dictionary<string, string>
实际上有效吗? 有人知道我的ѭ0passes通过导线后为何为空以及为什么
Dictionary<string, string>
起作用的想法。 [编辑] 这是我的结构的样子:
[DataContract]
public struct CustomStruct : IEquatable<CustomStruct>
{
    [DataMember]
    private string _prop;

    public string Prop { get { return _prop; } }

    public override int GetHashCode()
    {
        return Prop.GetHashCode();
    }

    public static bool operator ==(CustomStruct left, CustomStruct right)
    {
        ...
    }

    public static bool operator !=(CustomStruct left, CustomStruct right)
    {
        ...
    }

    public override bool Equals(object obj)
    {
        ...
    }
}
    
已邀请:
        这是一个可以满足您需求的工作示例 http://rocksolidknowledge.blob.core.windows.net/demos/CustomStructSerialization.zip 不幸的是,从您到目前为止提供的代码中,我看不到出了什么问题-猜测您在客户端和服务上的CustomStruct上具有不同的名称空间,因此序列化无法正常工作,但是看不到生成的代码而且自定义结构更完整,我无法分辨     
        尝试查看此FAQ是否有帮助。 WCF服务返回字典的数组     

要回复问题请先登录注册