Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Cyclic dependencies

Cyclic dependencies

Scheduled Pinned Locked Moved C#
helpwcfsysadminxmltutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lustuyck
    wrote on last edited by
    #1

    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!

    D 1 Reply Last reply
    0
    • L lustuyck

      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!

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups