title: WCF Service Custom Configuration
body: <p>In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service?  For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. </p>
  
  <p>I'm guessing this might be possible by implementing IServiceBehavior.</p>
  
  <p>i.e something like....</p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="MyBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug /&gt;
        &lt;customBehavior myCompany="ABC" /&gt;
      &lt;/behavior&gt;
      &lt;behavior name="MyOtherBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug /&gt;
        &lt;customBehavior myCompany="DEF" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  
  &lt;services&gt;
    &lt;service behaviorConfiguration="MyBehavior" name="MyNameSpace.MyService"&gt;
      &lt;endpoint address="" behaviorConfiguration="" binding="netTcpBinding" 
        name="TcpEndpoint" contract="MyNameSpace.IMyService" /&gt;
      &lt;endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
        name="TcpMexEndpoint" contract="IMetadataExchange" /&gt;
      &lt;host&gt;
        &lt;baseAddresses&gt;
          &lt;add baseAddress="net.tcp://localhost:4000/MyService" /&gt;
        &lt;/baseAddresses&gt;
      &lt;/host&gt;
    &lt;/service&gt;
    &lt;service behaviorConfiguration="MyOtherBehavior" name="MyNameSpace.MyOtherService"&gt;
      &lt;endpoint address="" behaviorConfiguration="" binding="netTcpBinding" 
        name="TcpEndpoint" contract="MyNameSpace.IMyOtherService" /&gt;
      &lt;endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
        name="TcpMexEndpoint" contract="IMetadataExchange" /&gt;
      &lt;host&gt;
        &lt;baseAddresses&gt;
          &lt;add baseAddress="net.tcp://localhost:4000/MyOtherService" /&gt;
        &lt;/baseAddresses&gt;
      &lt;/host&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p>Would set ABC on MyService and DEF on MyOtherService (assuming they have some common interface with a company name).</p>
  
  <p>Can anyone elaborate on how you implement this?</p>
  
  <p>TIA</p>
  
  <p>Michael</p>