Open GoogleCodeExporter opened 8 years ago
I'll investigate the array thing. Inheritance is via ProtoIncludeAttribute, or
MetaType.AddSubType (to define at runtime)
Original comment by marc.gravell
on 16 Jun 2012 at 2:02
I am also having an issue serializing arrays. The following line of code fails
if data is string[]
runtimeTypeModel.Serialize(stream, data);
(runtimeTypeModel is of type RuntimeTypeModel)
The exception message is: "Repeated data (a list, collection, etc) has inbuilt
behaviour and cannot be used as a subclass",
Stack trace:
protobuf-net.DLL!ProtoBuf.Meta.MetaType.BuildSerializer() Line 350 C#
protobuf-net.DLL!ProtoBuf.Meta.MetaType.Serializer.get() Line 278 + 0x11 bytes
C#
protobuf-net.DLL!ProtoBuf.Meta.RuntimeTypeModel.Serialize(int key, object
value, ProtoBuf.ProtoWriter dest) Line 400 + 0x51 bytes C#
protobuf-net.DLL!ProtoBuf.Meta.TypeModel.SerializeCore(ProtoBuf.ProtoWriter
writer, object value) Line 141 + 0x2e bytes C#
protobuf-net.DLL!ProtoBuf.Meta.TypeModel.Serialize(System.IO.Stream dest,
object value, ProtoBuf.SerializationContext context) Line 169 C#
protobuf-net.DLL!ProtoBuf.Meta.TypeModel.Serialize(System.IO.Stream dest,
object value) Line 156
Original comment by Franches...@gmail.com
on 15 Aug 2012 at 12:16
I am also have an issue when I use protobuf-net as serializer for WCF via
extension.
Arrays cannot be serialized via protobuf-net.
ProtoOperationBehavior new serializer tries to be created like this:
var model = RuntimeTypeModel.Default;
var serializer = XmlProtoSerializer.TryCreate( model, typeof( Int32[] ) );
Assert.IsNotNull( serializer );
var serializer0 = XmlProtoSerializer.TryCreate( model, typeof( String[] ) );
Assert.IsNotNull( serializer0 );
Both assertion won't pass.
The probem is also with
var serializerList0 = XmlProtoSerializer.TryCreate( model, typeof( List<String>
) );
Assert.IsNotNull( serializerList0 );
If introduce some DTO:
[ProtoContract]
[DataContract]
public class Dto
{
[DataMember]
[ProtoMember( 1 )]
private Int32 id;
public Int32 Id
{
get
{
return id;
}
set
{
id = value;
}
}
public Dto()
{
}
}
will be OK:
var serializerList = XmlProtoSerializer.TryCreate( model, typeof( List<Dto> ) );
Assert.IsNotNull( serializerList );
var serializer1 = XmlProtoSerializer.TryCreate( model, typeof( Dto ) );
Assert.IsNotNull( serializer1 );
Won't be passed:
var serializer2 = XmlProtoSerializer.TryCreate( model, typeof( Dto[] ) );
// Cannot find serializer for array
Assert.IsNotNull( serializer2 );
Original comment by Mikhail....@gmail.com
on 15 Jan 2014 at 10:05
Noticed the same this. The behavior doesn't recognize the array of a registered
type. Saw this posting that may be of help:
http://stackoverflow.com/questions/22509354/serializing-an-array-in-wcf-with-pro
tobuf-net
Original comment by john.kes...@gmail.com
on 18 Apr 2014 at 2:47
Original issue reported on code.google.com by
spa...@gmail.com
on 16 Jun 2012 at 1:09