4

Вопрос по c# – protobuf-net: обнаружена возможная рекурсия

Error: User Rate Limit Exceeded

[ERROR] FATAL UNHANDLED EXCEPTION: ProtoBuf.ProtoException: Possible recursion d etected (offset: 5 level(s)): red at ProtoBuf.ProtoWriter.CheckRecursionStackAndPush (object) <0x00127> at ProtoBuf.ProtoWriter.StartSubItem (object,ProtoBuf.ProtoWriter,bool) <0x0002f>

Error: User Rate Limit Exceeded

[ProtoContract] 
[ProtoInclude(100, typeof(PackageDirectory))]
[ProtoInclude(200, typeof(PackageFile))]
public abstract class PackageMember
{
   [ProtoMember(1)] 
   public virtual string Name { get; protected set; }

   [ProtoMember(2, AsReference=true)] 
   public PackageDirectory ParentDirectory { get; protected set; }  
}

[ProtoContract]
public class PackageDirectory : PackageMember
{
   [ProtoMember(3)]
   private Dictionary<string, PackageMember> _children;

   public PackageDirectory()
   {
      _children = new Dictionary<string, PackageMember>();
   }

   public PackageDirectory (string name, PackageDirectory parentDirectory)
      : this()
   {
      this.ParentDirectory = parentDirectory;
      this.Name = name;         
   }

   public void Add (PackageMember member)
   {
      _children.Add(member.Name, member);
   }
}

[ProtoContract]
public class PackageFile : PackageMember
{
   private Stream _file;
   private BinaryReader _reader;

   private PackageFile() 
   {}

   public PackageFile (string name, int offset, int length, PackageDirectory directory,  Stream file)
   {
      this.Name = name;
      this.Length = length;
      this.Offset = offset;
      this.ParentDirectory = directory;

      _file = file;
      _reader = new BinaryReader(_file);
   }

   [OnDeserialized]
   protected virtual void OnDeserialized(SerializationContext context)
   {
      var deserializationContext = context.Context as DeserializationContext;

      if (deserializationContext != null)
      { 
         _file = deserializationContext.FileStream;
         _reader = new BinaryReader(_file);
      }
   }

   [ProtoMember(3)]
   public int Offset { get; private set; }

   [ProtoMember(4)]
   public int Length { get; private set; }
}

Error: User Rate Limit ExceededProtoBuf.ProtoWriter.RecursionCheckDepthError: User Rate Limit Exceededversion of protobuf-netError: User Rate Limit Exceededv2 (rev 491).

Error: User Rate Limit ExceededProtoBuf.ProtoWriter.RecursionCheckDepthError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededMono-2.10-8 on Windows 7 Professional 64-bit

Error: User Rate Limit Exceeded

var value = new PackageDirectory();
RuntimeTypeModel.Default.Deserialize(ms, value, typeof(PackageDirectory), new SerializationContext {
   Context = new DeserializationContext {
   FileStream = _file,
}});

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Apr 09, 2012, 3:51 PMот

Error: User Rate Limit Exceeded<b>exact</b>Error: User Rate Limit Exceeded

Apr 09, 2012, 5:23 PMот

Error: User Rate Limit Exceeded

Apr 09, 2012, 9:03 AMот

Error: User Rate Limit Exceeded

Apr 09, 2012, 5:44 PMот

Error: User Rate Limit Exceeded

Apr 09, 2012, 5:52 PMот

1ответ

6

Error: User Rate Limit ExceededreferenceError: User Rate Limit Exceededonly enabledError: User Rate Limit ExceededRecursionCheckDepthError: User Rate Limit ExceededquiteError: User Rate Limit ExceededRecursionCheckDepthError: User Rate Limit Exceeded

Error: User Rate Limit ExceededAsReferenceError: User Rate Limit Exceeded

RelatedQuestions