title: ProtoBuf-Net , Open generic types serialization/ deserialization
body: <p>I have the following Type:</p>
  
  <pre><code>Class Command&lt;TData&gt; : Base Where TData : I
  </code></pre>
  
  <p>In runtime this class is build (with specific TDATA) and Serialized.
  I have 2 issues( I'm using V2 ):
  1) When I'm adding this type to runtime modal :</p>
  
  <pre><code>var meta = this._modal.Add(type, false)
                               .Add(this.GetDMProperties(type).Select(p =&gt; p.Name)
                               .ToArray());
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>2) If i try to skip it at start up and try to do it on demand like below:</p>
  
  <pre><code>if (this._modal.CanSerializeContractType(objectType) == false)
              {
                  this._modal.Add(objectType, false);
                  this._modal.CompileInPlace();
              }
  </code></pre>
  
  <p>CanSerializeContractType returns true, but in practice only the base data is serialized.</p>
  
  <p>My question is what is the practice of adding this type to modal without adding all permutations on design time if possible ?</p>