Open generic types Serialization/ Deserialization

605 views
Skip to first unread message

eyan

unread,
Feb 5, 2012, 7:37:12 AM2/5/12
to Protocol Buffers
Hi,
I have a Type :

Command<TData> : Base where TData : ISomething.

TData are POCOs (DataContracts).

Im using ProtoBuf.net V2, and I'm registering the types to the Modal
on run time.
I'm having 2 issues:

1) on MetaType.Add(properties names) i get ObjectReference exception
when the Type includes Generic Type property.
Unhandled Exception: System.NullReferenceException: Object reference
not set to
an instance of an object.
at ProtoBuf.Meta.TypeModel.ResolveProxies(Type type) in C:\Dev
\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 952
at ProtoBuf.Meta.RuntimeTypeModel.FindWithoutAdd(Type type) in C:
\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:line 118
at ProtoBuf.Meta.ValueMember..ctor(RuntimeTypeModel model, Type
parentType, Int32 fieldNumber, MemberInfo member, Type memberType,
Type itemType, Type defaul
tType, DataFormat dataFormat, Object defaultValue) in C:\Dev\protobuf-
net\protobuf-net\Meta\ValueMember.cs:line 75
at ProtoBuf.Meta.MetaType.AddField(Int32 fieldNumber, String
memberName, Type itemType, Type defaultType, Object defaultValue) in C:
\Dev\protobuf-net\protobu
f-net\Meta\MetaType.cs:line 1165
at ProtoBuf.Meta.MetaType.Add(String[] memberNames) in C:\Dev
\protobuf-net\protobuf-net\Meta\MetaType.cs:line 1046

2) If I'm skipping the Open generic types and im trying to register
them at serialization :
if (this._modal.CanSerializeContractType(objectType) == false)
{
this._modal.Add(objectType, false);
this._modal.CompileInPlace();
}

I get true in CanSerializeContractType, the type is serialized/
deserialized but only the base class (default values to all others).

What is the practice to do so without adding all permutations at
design time ?

Thanks,
Eyan.

eyan

unread,
Feb 7, 2012, 2:24:05 AM2/7/12
to prot...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages