title: How to serialize a Func<int, int> (or even a general delegate) type field with DataContract/DataMember in WCF
body: <p>I am trying to serialize a <code>Func&lt;int, int&gt;</code> field marked with <code>[DataMember]</code>, of a class marked with <code>[DataContract]</code>, whose target or Lambda expression definition is also part of the contract or could even be in the class itself.</p>
  
  <p>I am using a custom <code>DataContractResolver</code> which works perfectly well when I unmark the <code>Func</code> field but when I mark it, it does not resolve a <code>System.DelegateSerializationHolder</code> type needed for the serialization. I tried to add this type to my custom <code>DataContractResolver</code> but I can't find it in the System namespace.</p>
  
  <p>I could redefine it in the <code>[OnDeserialized]</code> method of each client class that uses this class but then I would need to do this every time I use this class, which of course I would like to avoid (client classes are also part of the <code>DataContract</code>).</p>
  
  <p>This serialization is used for the time being for saving the state of the app to disk, so saving delegates (or even events which I am not interested in) makes logical sense as it is all part of the object graph.</p>
  
  <p>So how can I serialize this <code>Func&lt;int, int&gt;</code> using WCF's <code>DataContract</code>?</p>