zling2001 / protobuf-net

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

No parameterless constructor found for BaseEntry #393

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
oparin.epm@gmail.com
==============

What steps will reproduce the problem?
The problem is that I can't reliably reproduce it.

What is the expected output? What do you see instead?
-

What version of the product are you using? On what operating system?
r640, win7 64b

Please provide any additional information below.
The class I am serializing have a parent class, and properties I serialize are 
defined in both of them. I am using protobuf in an extension of 
BlockingCollection that stores elements on disk when certain limit is reached, 
that blocking collection is used in several threads.

The issue happens randomly, I mean I store only that one class, and that 
exception can happen after an hour of work or immediately.

I have noticed one thing - that class of mine is defined in one solution, and I 
have no issues with protobuff there. In second solution I am referencing a dll 
with those classes, and when I look into metadata I dont see protobuff 
attributes there. Can it be problem? E.g.:

Solution 1 class:
[DataContract, ProtoContract]
    [ProtoInclude(100, typeof(OrderBookEntry))]
    [ProtoInclude(99, typeof(OrderLogEntry))]
    public abstract class BaseEntry
    {
        [DataMember, ProtoMember(1)]
        public string Symbol { get; set; }

       [DataMember, ProtoMember(2)]
        public string System { get; set; }
    }

Solution 2 class:
    [DataContract]
    public abstract class BaseEntry
    {
        protected BaseEntry();

        [DataMember]
        public string Symbol { get; set; }
        [DataMember]
        public string System { get; set; }
     }

Original issue reported on code.google.com by Oparin....@gmail.com on 27 Jun 2013 at 2:19

GoogleCodeExporter commented 9 years ago
ProtoBuf.ProtoException: No parameterless constructor found for BaseEntry
   at ProtoBuf.Meta.TypeModel.ThrowCannotCreateInstance(Type type) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 1368
   at proto_6(Object , ProtoReader )
   at ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Read(Object value, ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\Serializers\CompiledSerializer.cs:line 57
   at ProtoBuf.Meta.RuntimeTypeModel.Deserialize(Int32 key, Object value, ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:line 783
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 expectedField, TypeResolver resolver, Int32& bytesRead, Boolean& haveObject, SerializationContext context) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 352
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 expectedField, TypeResolver resolver, Int32& bytesRead) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 296
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 fieldNumber) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 256
   at ProtoBuf.Serializer.DeserializeWithLengthPrefix[T](Stream source, PrefixStyle style, Int32 fieldNumber) in c:\Dev\protobuf-net\protobuf-net\Serializer.cs:line 303
   at ProtoBuf.Serializer.DeserializeWithLengthPrefix[T](Stream source, PrefixStyle style) in c:\Dev\protobuf-net\protobuf-net\Se

Original comment by Oparin....@gmail.com on 28 Jun 2013 at 8:12