title: Generally accepted way to avoid KnownType attribute for every derived class
body: <p>Is there a generally accepted way to avoid having to use KnownType attributes on WCF services? I've been doing some research, and it looks like there are two options:</p>
  
  <ol>
  <li><a href="http://blogs.msdn.com/b/carlosfigueira/archive/2011/09/21/wcf-extensibility-data-contract-resolver.aspx" rel="noreferrer">Data contract resolver</a></li>
  <li><a href="https://stackoverflow.com/a/10792018/279516">NetDataContractSerializer</a></li>
  </ol>
  
  <p>I'm not a big fan of having to statically add KnownType attributes every time I add a new type, hence wanting to avoid it.</p>
  
  <p>Is there a third option that should be used? If so, what is it? If not, which of the above two options are the right way to go?</p>
  
  <p><strong>Edit - use a method</strong></p>
  
  <p>A third option would be to use reflection</p>
  
  <pre><code>[DataContract]
  [KnownType("DerivedTypes")]
  public abstract class FooBase
  {
      private static Type[] DerivedTypes()
      {
          return typeof(FooBase).GetDerivedTypes(Assembly.GetExecutingAssembly()).ToArray();
      }
  }
  </code></pre>