title: Create WCF endpoint configurations in the client app, in code?
body: <p>I am trying to consume a WCF web service from a .NET client application, and I think I need to be able to programmatically create endpoints, but I don't know how. I think I need to do this because, when I try to run the application, I am getting the following error:</p>
  
  <blockquote>
    <p>Could not find default endpoint
    element that references contract
    'IEmailService' in the ServiceModel
    client configuration section. This
    might be because no configuration file
    was found for your application, or
    because no endpoint element matching
    this contract could be found in the
    client element.</p>
  </blockquote>
  
  <p>While troubleshooting this error, I created a simple windows forms application, in which I try to consume the same web service. With this test application I can connect to the web service successfully, and I get a valid response. But, I can reproduce the exact error cited above within in my test app by removing the system.serviceModel node and all of its child nodes from the application's app.config file (I might not have to remove ALL of that section, I'm not sure). So, my first thought was that I need to add that section to the app.config file for the real app, and everything should be fine. Unfortunately, for ridiculous reasons that I won't get into here, that is not an option. So, I am left with having to generate this information in code, inside the client app.</p>
  
  <p>I am hoping someone here can help me work through this, or can point me toward a good resource for this sort of problem. </p>
  
  <p>Is it possible to create endpoint configurations in the client app, in code?</p>