title: protobuf-net throws exception about invalid wire-type, when passing single enum values to WCF service
body: <p>Calling the following method on my wcf service….</p>
  
  <pre><code>ObservableCollection&lt;PatientViewModel&gt; Search(List&lt;string&gt; searchTerms, SearchNature nature, SearchMode mode, List&lt;SearchField&gt; fields)
  </code></pre>
  
  <p>Result in the following exception…</p>
  
  <pre><code>ProtoBuf.ProtoException, protobuf-net, Version=2.0.0.627, Culture=neutral, PublicKeyToken=75e2634e27c46854
  
  Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354
  
  ProtoBuf.ProtoReader.ReadInt32()
  proto_4(Object , ProtoReader )
  ProtoBuf.ServiceModel.XmlProtoSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
  System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)
  System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
  System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)
  System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
  System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
  System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
  System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp;amp; rpc)
  System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
  System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
  System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)
  System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
  </code></pre>
  
  <p>NOTE: 
  If I remove the 2nd and 3rd parameters. So the method is…</p>
  
  <pre><code>ObservableCollection&lt;PatientViewModel&gt; Search(List&lt;string&gt; searchTerms, List&lt;SearchField&gt; fields)
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>The parameter fields is an enum list and that deserializes with no issue.</p>
  
  <p>Why would a single enum value cause the above exception?</p>
  
  <p>Thanks in advance.</p>
  
  <p>For your reference...</p>
  
  <pre><code>[DataContract]
  public enum SearchNature
  {
      [EnumMember] None,
      [EnumMember] Letters,
      [EnumMember] Numbers
  }
  
  [DataContract]
  public enum SearchMode
  {
      [EnumMember] None,
      [EnumMember] BeginsWith,
      [EnumMember] Contains
  }
  
  [DataContract]
  public enum SearchField
  {
      [EnumMember] None,
      [EnumMember] FirstName,
      [EnumMember] LastName,
      [EnumMember] PatientId,
      [EnumMember] PriorId,
      [EnumMember] PhoneNumber,
      [EnumMember] DateOfBirth
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Additionally, if I change ProtoOperationBehavior to use the default serializer when the type is an enum instead of XmlProtoSerializer, the service calls work fine.</p>
  
  <pre><code>public override XmlObjectSerializer CreateSerializer(Type type, System.Xml.XmlDictionaryString name, System.Xml.XmlDictionaryString ns, IList&lt;Type&gt; knownTypes)
  {
      if (type.IsEnum) return base.CreateSerializer(type, name, ns, knownTypes);
      if (model == null) throw new InvalidOperationException("No Model instance has been assigned to the ProtoOperationBehavior");
      return XmlProtoSerializer.TryCreate(model, type) ?? base.CreateSerializer(type, name, ns, knownTypes);
  }
  </code></pre>