views:

53

answers:

1

I have a web method called from Jquery to display a hierarchical tree object. The return value is a List (Of T) , where T is hierarchical, a parent-child relationship. traversal will be from parent to child.

1) .Net automatically converts the return value from webmethod to JSON to send it back to js client. At that point it throws a circular ref error. I checked code and only the parent calls the child and not the other way. But we use structureMap for dependency injection. Could this be causing the circular ref ?

Note: I have a test project without structureMap to display the hiearchical tree structure and I have no problems with the json serialization.

Any ideas on how to debug this will be helpful?

A: 

It is likely that your child object references some third object, which may reference another object, etc, and one of the objects down the chain eventually references the parent object (or one of the other objects in the chain).

It should not have anything to do with StructureMap. You should be able to easily prove that by writing a test that creates the instance you are trying to return, and run it through the JSON serializer (do not use StructureMap at all in the test).

Joshua Flanagan