From: kalyan on 17 Sep 2009 13:39 I ran into the same problem and THE ONE OF SOLUTION IS to Use [ScriptIgnore] atribute .. it will solve the problem. add system.web.extensions reference and add namespace: Using System.Web.Script.Serialization. If you still have questions..Read on..for some detailed explanation.. i have a User class with.. using System; using System.Collections.Generic; using System.Linq; using System.Web; using Iesi.Collections.Generic; using System.Runtime.Serialization; namespace RAPortal.Core.Entities { public class User { private int _userId; private string _firstName; private string _lastName; private IList<Application> _applications; private IList<Group> _groups; private IList<ApplicationRequest> _applicationRequests; Properties.. public virtual int UserId { get { return _userId; } set { _userId = value; } } public virtual string Title { get { return _title; } set { _title = !String.IsNullOrEmpty(value) ? value.ToUpper().Trim() : null; } } public virtual IList<Group> Groups { get { return _groups; } set { _groups = value; } } public virtual IList<UserPrivilege> UserPrivileges { get { return _userPrivileges; } set { _userPrivileges = value; } } public virtual IList<UserRole> UserRoles { get { return _userRoles; } set { _userRoles = value; } } ....so on... and I have Groups class.. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Script.Serialization; using System.Runtime.Serialization; namespace RAPortal.Core.Entities { public class Group { private int _groupId; private string _name; private IList<User> _users; public virtual int GroupId { get { return _groupId; } set { _groupId = value; } } public virtual string Name { get { return _name; } set { _name = !String.IsNullOrEmpty(value) ? value.ToUpper().Trim() : null; } } [ScriptIgnore] public virtual IList<User> Users { get { return _users; } set { _users = value; } } } } Since User is referenced in the groups.. the json think that it is Circular reference and It will throw an exception..so the fix is to add [ScriptIgnore] on top of the User. And add the reference and namespace to this class like it.. It solved my problem .. I am sure there are better ways out there !!! Cheers... And remember you should add [scriptIgnore] only in the groups class and not in the Users class.. Posted as a reply to: Re: Circular Reference. I really need help ... thanks. "shapper" <mdmoura(a)gmail.com> wrote in message news:78860aad-2ee6-4156-9bde-fd6d688a69f4(a)w24g2000prd.googlegroups.com... Without the definition for Json() method, this doesn't tell much. EggHeadCafe - Software Developer Portal of Choice WCF Workflow Services Using External Data Exchange http://www.eggheadcafe.com/tutorials/aspnet/3d49fa0d-a120-4977-842a-6dafb17b6d74/wcf-workflow-services-usi.aspx
|
Pages: 1 Prev: Event to trap VS Stop Debugging? Next: Function param expects IEnumerable<ClassName> |