ericvana / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Serialization Error #294

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

While serializing I am getting error "Possible recursion detected
(offset: 2 level(s))". I have check tag of every ProtoMember of each
class I am using. Each tag is unique but still finding this error. How
can I handle this. I am new to Protocol Buffer.

I am using protobuf-new r480;

Original issue reported on code.google.com by farooqmu...@gmail.com on 4 Jun 2012 at 11:30

GoogleCodeExporter commented 9 years ago
Recursion doesn't relate to tag numbers; do you have any kind of example? 
usually this relates to something like a .Parent property.

Original comment by marc.gravell on 4 Jun 2012 at 12:19

GoogleCodeExporter commented 9 years ago
I have two classes, 1- Asset and 2- Plant. Asset is the parent class of Plant, 
I have used ProtoInclude in Asset class typeof Plant. 
Following is the sample code of Asset and Plant:
//Asset Class
[ProtoContract(SkipConstructor = true)]
[ProtoInclude(500, typeof(Plant))]
public class Asset : ISerializable, TreeList.IVirtualTreeListData, IDisposable, 
ICloneable
{
          //Constructor
    [ProtoMember(1, DynamicType = true)]
        public List<Asset> AllAssets
        {
            get
            {
               //Code
            }
        }

        [ProtoMember(2, DynamicType = true)]
        public List<Asset> AssetHierarcy
        {
            get
            {
                //Code
            }
        }

        [ProtoMember(3, DynamicType = true)]
        public List<Asset> ChildAssets { get; private set; }
}

//Plant Class
[ProtoContract(SkipConstructor = true)]
    public class Plant : Asset
    {
        //Costructor

        [ProtoMember (101, DynamicType = true)]
        public Parameter Altitude { get; set; }

        [ProtoMember(105, DynamicType = true)]
        public Asset Blowers
        {
            get
            {
               //Code
                return null;
            }
        }
    }

While serializing I am getting error "Possible recursion detected
(offset: 2 level(s))".

Original comment by farooqmu...@gmail.com on 5 Jun 2012 at 4:58

GoogleCodeExporter commented 9 years ago
Is there any minimum example of some fake data that actually shows the problem, 
that I can use to repro? Also, all those DynamicType are unnecessary (and 
should probably be removed).

Original comment by marc.gravell on 5 Jun 2012 at 6:22