The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Circular reference during serializing?

Last post 10-16-2007, 6:51 AM by Mike.Griffin. 20 replies.
Page 1 of 2 (21 items)   1 2 Next >
Sort Posts: Previous Next
  •  09-29-2007, 10:56 PM 5388

    Circular reference during serializing?

    Hey,

    I'm trying to pass an entity back over a web service and keep getting this error - runtime not compile time.

    "A circular reference was detected while serializing an object of type 'mytabletype'.

    Any ideas?

    thanks

    Craig

  •  09-30-2007, 5:10 AM 5393 in reply to 5388

    Re: Circular reference during serializing?

    That seems strange since we do not "yet" serialize any of the hierarchical structure? All of the hierarchical sub-objects are marked as [XmlIgnore]. If you are operating on both sides of the web service I highly recommend our proxy's, they maintain object state and can make your life real easy. However, let's figure out this issue first. Try putting [NonSerialized] above all of your hierarchical objects in that class and see if it helps. Although, we've done a lot of webservice stuff and never seen any attempt to serialize them.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  09-30-2007, 7:51 AM 5400 in reply to 5393

    Re: Circular reference during serializing?

    ok Mike I'll give that a try shortly. In the mean time how do you normally send your objects across web services? or don't you? In the past I would create a struct and just map what I needed but its a lot of work.

    As an FYI I am sending this object over a (asp.net ajax Page Method) i.e. from the actual page rather than an extra web service although I wouldn't see why it would get serialized any differently.

    -c
     

  •  09-30-2007, 7:56 AM 5401 in reply to 5393

    Re: Circular reference during serializing?

    Mike - just checked (should have known) but this particular class has no hierarchy, its a simple flat table with a primary key.

    thanks,

    Craig 

  •  09-30-2007, 8:36 AM 5402 in reply to 5401

    Re: Circular reference during serializing?

    This BLOG post really helps to explain EntitySpaces and WebServices (there is even a zip file on that post that will allow you to run the client and hit our hosted web services). It all depends on if you are on both sides of the webservice or just one?  This POST shows you how to create our Proxies, which are not just for WCF but can be used for web services. There is

    If you are sending collections one way their is an implicit operator in your collection that can present a nice xml format, notice that the return type is List<Employee> and it is converted automatically, we do this via an implicit operator.

     

    Code:
    public List GetAllEmployees()
    {
        EmployeeCollection emps = new EmployeeCollection();
    
        if (emps.LoadAll())
            return emps;
        else
            return null;
    }
     

    again, the Proxy is even better if you're on both sides of the equasion. 

    To solve the issue you are having you need to the code snippet (be sure and use the code button). We have no such issues with webservices. Have you added data members to the custom class that are being serialized? That would be my guess as the cause of the problem, especially a circular reference. 

     

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  09-30-2007, 8:52 AM 5403 in reply to 5402

    Re: Circular reference during serializing?

    Thanks, I will try the proxy as I am on both sides. To answer your question - I never add anything to the custom classes so its just whatever is generated. If I still get stuck I'll post the classes.

     

    -c 

  •  09-30-2007, 9:13 AM 5404 in reply to 5403

    Re: Circular reference during serializing?

    ok, the proxy threw the same exception so here is some code:

    Code:
        [WebMethod]
    public static ShippingratesProxyStub GetFlatRate()
    {
    return new ShippingratesProxyStub(Shipping.GetFlatRate());
    }

     


  •  09-30-2007, 10:04 AM 5405 in reply to 5404

    Re: Circular reference during serializing?

    What version of ES are you using? Please try this on another class. Please post the entire call stack. Also, thanx for the code, but perhaps it would be better to email whole classes to support@entityspaces.net. There's something wrong here because we have lots of users doing just such a thing.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  09-30-2007, 10:13 AM 5406 in reply to 5405

    Re: Circular reference during serializing?

    I am using version 2007.0.819.0 - I tried another class and it also failed. The call stack just has the one line, maybe I'm doing something wrong in trying to capture that.

    Anything else I can post?

    -c 

     

  •  09-30-2007, 10:27 AM 5407 in reply to 5405

    Re: Circular reference during serializing?

    I just upgraded to the latest version, same problem - I'm wondering if its an issue with asp.net ajax.
  •  09-30-2007, 7:59 PM 5426 in reply to 5407

    Re: Circular reference during serializing?

    ok - tried even re-installing asp.net ajax, still no luck. I also tried a JSON serializer to see if it could serialize the object and got these errors - maybe it will help track it down:

     

    -        base    {"Use 'Equal' not 'Equals'"}    System.Exception {System.NotImplementedException}
            Source    "EntitySpaces.Interfaces"    string
            StackTrace    "   at EntitySpaces.Interfaces.esQueryItem.Equals(Object o)\r\n   at System.Collections.Generic.ObjectEqualityComparer`1.IndexOf(T[] array, T value, Int32 startIndex, Int32 count)\r\n   at System.Array.IndexOf[T](T[] array, T value, Int32 startIndex, Int32 count)\r\n   at Newtonsoft.Json.JsonSerializer.WriteMemberInfoProperty(JsonWriter writer, Object value, MemberInfo member, String propertyName)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeObject(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeValue(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JsonSerializer.WriteMemberInfoProperty(JsonWriter writer, Object value, MemberInfo member, String propertyName)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeObject(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeValue(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JsonSerializer.WriteMemberInfoProperty(JsonWriter writer, Object value, MemberInfo member, String propertyName)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeObject(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeValue(JsonWriter writer, Object value)\r\n   at Newtonsoft.Json.JavaScriptConvert.SerializeObject(Object value, JsonConverter[] converters)\r\n   at Newtonsoft.Json.JavaScriptConvert.SerializeObject(Object value)"    string
     

  •  10-01-2007, 5:12 AM 5439 in reply to 5426

    Re: Circular reference during serializing?

    Somewhere in your query you are using .Equals instead of .Equal, correct that and try normal serialization.

    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  10-01-2007, 7:01 AM 5441 in reply to 5439

    Re: Circular reference during serializing?

    Scott,

    This is the only code I wrote :

     

    Code:
    Extensions e = new Extensions();
    e.LoadByPrimaryKey(1);
    return e; // tried this with JSON too.

     
  •  10-01-2007, 7:27 AM 5444 in reply to 5441

    Re: Circular reference during serializing?

    Craig, create a tiny app based on one table and send that to us. We have no such problems in ES that we are aware of. If you can use Northwinds Employees Table, you don't even have to do a webservice, just try serializing like we do in our BLOG post on webservices. You will need to send us something than repro's this. I do think this will turn out not to be a bug, we test serialization in our Unit tests and it is used quite heavily by our users. Again, please send us something that will repro this.

    [modified]

    Why not just create a normal webservice, and hit it from the browser, if it doesn't error then you need to track down what you are adding to the situation that is causing it?  My guess is something you are doing is using a different form of serialization, ignoring [XmlIgnore] tags and [NonSerialized] tags ...


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  10-01-2007, 7:41 AM 5445 in reply to 5444

    Re: Circular reference during serializing?

    Mike, that worked - I had made a simple webservice rather than a page method but I was still calling it from the web client - I tried via the browser and it definately serialized ok so I'm guessing this is an asp.net ajax bug.

    thanks

    Craig
     

Page 1 of 2 (21 items)   1 2 Next >
View as RSS news feed in XML