Cyclic dependencies
-
Hi, imagine a Folder object, that contains a list of File objects. Each File object has a Folder parent. So we have a cyclic dependency here. When I try to return such structure with a web service, I get the following error: System.Web.Services.Protocols.SoapException: Server was unable to process request. --> There was an error generating the XML document. --> A circular reference was detected while serializing an object of type Folder. I've read that XmlSerializer can't handle cyclic dependencies. Does this mean that I cannot use web services to return such a structure, or is it a bug and will it be possible in 2.0 for example? Is there some kind of workaround for now? Thanks in advance!
-
Hi, imagine a Folder object, that contains a list of File objects. Each File object has a Folder parent. So we have a cyclic dependency here. When I try to return such structure with a web service, I get the following error: System.Web.Services.Protocols.SoapException: Server was unable to process request. --> There was an error generating the XML document. --> A circular reference was detected while serializing an object of type Folder. I've read that XmlSerializer can't handle cyclic dependencies. Does this mean that I cannot use web services to return such a structure, or is it a bug and will it be possible in 2.0 for example? Is there some kind of workaround for now? Thanks in advance!
I've never tried this on a WebService, but some time ago I needed to serialize a circular reference with the XmlSerializer and it didn't work, but the SoapFormatter could. Since web services use soap, it should work, but I'm only guessing here... Yes, even I am blogging now!