WCF - Serialization Exception due to Circular reference
I am using DataContract with preserveObjectReferences set to false (default). Under any circumsatnces will it cause a Circular reference and cause Serial开发者_如何学Pythonization Exception?
if yes, could you please xplain with a sample scenario?
Thanks
Lijo
Yes, absolutely, if you turn the flag off, this simple scenario would result in a serialization exception:
public static class X
{
public static A GlobA;
public static B GlobB;
static
{
GlobA = new A();
GlobB = new B();
GlobA.someB = GlobB;
GlobB.someA = GlobA;
}
}
[DataContract]
public class A
{
[DataMember]
public B someB = X.GlobA;
}
[DataContract]
public class B
{
[DataMember]
public A someA;
}
Now try to serialize an instance of A...
精彩评论