我有一个WCF服务,我试图从客户端发送一个
当我将字典发送到服务器时,不会抛出任何错误。但是当我尝试遍历我的字典时,它是空的。
奇怪的是,
有人有想法为什么我的
[编辑] 这是我的结构体的样子:
Dictionary<CustomStruct, int>
到服务器。我的WCF服务使用默认的BasicHttpBinding。当我将字典发送到服务器时,不会抛出任何错误。但是当我尝试遍历我的字典时,它是空的。
奇怪的是,
Dictionary<string, string>
实际上可以工作?!有人有想法为什么我的
Dictionary<CustomStruct, int>
在通过网络传输后为空,并且为什么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)
{
...
}
}
CustomStruct
的布局是什么? - linuxuser27CustomStruct
代码吗?它被标记为“可序列化”了吗? - Bala R