1

I have three classes MainMenu, SubMenu and Secondary SubMenu. I have a cascading drop down box which is used when creating Secondary Submenu. A main menu is selected which then shows a drop down with sub menus. When I select an item in the MainMenu drop-down box I get an error:

System.InvalidOperationException: A circular reference was detected while serializing an object of type 'System.Reflection.Module'.

The SubMenu references the MainMenu and the SecondaryMenu references the SubMenu.

I'm not sure where to begin looking for the error?

2 Answers 2

2

Well, what is SubMenu?

This typically happens with tree serializers (such as XmlSerializer and JSON implementations, etc) if you have a "parent" relationship. Does your sub-menu know about its parent? Can you make this an internal property, perhaps? Or mark it to be ignored?

Sign up to request clarification or add additional context in comments.

Comments

1

The Json methods convert any object structure to Json using reflection/recursion if an object A references another object B that in turn references object A you got yourself an infinite loop. Does submenu have parent and children properties ? If so in most cases you only need the 1.

3 Comments

Thanks. I've have three menus. A Main Menu, a Sub Menu and then a Secondary Sub Menu. The Sub Menu references the Main Menu and the Secondary Sub Menu references the Sub Menu, is this wrong?
Ok, so you pass the JSONResult an array of SubMenu's which link back to MainMenu. Is there any property on main menu that could possibly link back ? Perhaps you could update your question describing the three classes and their public properties ? That way others can have a look and answer as well :)
I had added another property to the MainMenu which references a Css Style. When I remove the Css Style property the cascading menus works again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.