WCF is fantastic for easy communication between applications. WCF is normally implemented using binding configurations embedded in each application. You usually have configuration for your server, and also your endpoint for your client. I found myself in a situation in which I had no readily available configuration file to use, as well, the endpoint address was dynamic itself based on the application that is consuming this library. Thus, I began searching on how to programmatically setup your client endpoint. Turns out, it is not that hard. Check it out:
In my example, I have created a custom statistics posting service. So, IStatService and StatResults is just the service contract created for must WCF service (these would change with your application). Notice the string passed in indicating the location of the service. This obviously creates a BasicHttpBinding configuration only, but you should be able to alter any of your standard WCF Configuration settings programmatically here too (make sure they match the service though J). With this above implementation I have NO config file (and the endpoint address is passed to this code – not hardcoded as shown above).