title: C# const associated with an interface for a WCF service definition
body: <p>I am writing a WCF service and have a default <code>Fault</code> implementation that I am handling with an <code>IErrorHandler.ProvideFault</code>:</p>
  
  <pre><code>    public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
      {
          log.Error("ProvideFault called. Converting Exception to AdministrationFault....");
  
          var defaultFault = new FaultException&lt;AdministrationFault&gt;(
              new DefaultFault { Reason = error.Message }, error.Message);
  
          fault = Message.CreateMessage(version,
              defaultFault.CreateMessageFault(),
              DEFAULT_FAULT_ACTION);
      }
  </code></pre>
  
  <p>The const you see <code>DEFAULT_FAULT_ACTION</code> needs to have the same value as the <code>FaultContractAttribute</code> of my service.  Given that my service is defined in an interface:</p>
  
  <pre><code>[ServiceContract(Namespace = "http://example.com/service/IFooService")]
  public interface IFooService
  {
      [OperationContract]
      [FaultContract(typeof(DefaultFault),
          Action = "http://example.com/service/IFooService/fault/DefaultFault")]
      void AddUser(UserInfo userInfo, string password);
  }
  </code></pre>
  
  <p>I cannot create <code>const</code> variables to store the namespace/action values.  So for now I am forced to create a class to store the constants:</p>
  
  <pre><code>public class StupidHackyConstClass {
      public const string NAMESPACE = "http://exampl.com/service/IFooService";
      public const string DEFAULT_FAULT_ACTION = NAMESPACE + "/fault/DefaultFault"
  }
  </code></pre>
  
  <p>So that i can refactor the interface attributes and the error handler implementation to use common values.  I know a class for consts is a <em>terrible</em> anti-pattern, but it seems i am backed into a hole here...  Any suggestions?</p>