title: .NET - deploying a WCF client, without an app.config
body: <p>I'm writing a client to a WCF service.  This is a single app in a larger system that includes modules written in C#, C++, VB, and Java.  All of the apps share common configuration and logging mechanisms, regardless of what language they were written in.</p>
  
  <p>I'd like to figure out how to build the client application so that it will run without an app.config.  Why?  Because most of what is in the app.config is boilerplate that the sysadmins shouldn't be allowed to change, and what settings the sysadmins should be allowed to change should be in the system-wide configuration, and not in an app.config file sitting in the bin directory.</p>
  
  <p>Case in point - the client's app.config currently looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;customBinding&gt;
          &lt;binding name="WSHttpBinding_ICourierService"&gt;
            &lt;security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation"
              ...
            &lt;/security&gt;
            &lt;textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
              messageVersion="Default" writeEncoding="utf-8"&gt;
              &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
            &lt;/textMessageEncoding&gt;
            &lt;httpTransport manualAddressing="false"
              ...
              useDefaultWebProxy="true" /&gt;
          &lt;/binding&gt;
        &lt;/customBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:57102/MyService.svc"
          ...
          &gt;
          &lt;identity&gt;
            &lt;dns value="localhost" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>It's a bunch of opaque boilerplate that the sysadmins shouldn't have to deal with.  Most of it was inserted by Visual Studio.  I've made one change in the file - I increased the max size in <code>&lt;readerQuotas/&gt;</code>.  But that's a change that I don't want the sysadmins to mess with.  And there's nothing else in the file I want the sysadmins to mess with except for <code>&lt;endpoint address=""/&gt;</code>.</p>
  
  <p>And I'm pulling the endpoint address from the system-wide configuration, and setting it in code.  There's nothing in this file that should be user-editable.</p>
  
  <p>So, how do I configure things so that I don't need to have it present?</p>
  
  <p>Can I embed it as a resource in the assembly, and hook into the app.config load process, the way I do with required DLLs?</p>
  
  <p>Is the only choice to create code to configure things, the way I'm using code to set the endpoint address?  Create the necessary bindings, etc., in code?  How, then, do I know what code to write, given these chunks of opaque XML?</p>