Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xmlSerializer circular reference error

Status
Not open for further replies.

vcllvc

Programmer
Jul 12, 2001
136
US
hey, all

I am having a problem to serialize a complex object into xml, hope someone can help me.

To make it short, I have two objects: "Contract" and "Rate"

The Contract has a property of Rate object as a circular reference. When I use an XmlSerializer to serialize the Contract, the framework thrown me an error "A circular reference was detected while serializing an object of type xyz"

Is there a way to work it around?

Thanks in advance.

 
One object that contains another is not circular.

Object1
- Object2

its when object1 contains object2 which contains object1 again.

Object1
- Object2
-Object1
-Object2
....
 
yes, I missed the detail. Thanks.

So, is there any way to work it around?
 
Perhaps you can create a hashtable of "visited" objects, and check it's contents before serializing an object.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
You could also create your own custom serialization/deserialization tools. Takes some work though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top