Last night I had a problem with getting WCF to work with my application. I had a very simple scenario intermixed in a multi-layered application. The error I kept getting was

Could not find default endpoint element that references contract MyServiceHost.IMyService' 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.

I kept looking at the config files using the SvcConfigEditor.exe utility and made sure the client and the server configurations were set up properly and matched each other. I was convinced I had done it right, so I started googling for answers. I was sure it was something simple. Well, it turns out that it was a simple mistake I made. I did not find anything by googling, so I figured I would post this in hopes of helping others and myself in case I do this again someday :)

My application has a UI layer for the views (using WinForms, WPF, etc) and a second project layer for presenters (using the MVP passive view pattern). The presenter project is what communicates with the WCF Service via its host but the app runs from the UI layer. This means that the client config must be accessible from the UI's exe. I had placed the config file in the presenter project because this is where I had set up the service reference to the WCF services. Once I realized that I forgot to copy the config file to the UI project I had a "doh!" moment.

So in short, the problem It turns out my problem was quite simply resolved once I realized I forgot to put my app.config file in the bin folder of my multi layered application's startup project.

   <div class="wlWriterSmartContent" id="scid:B3E14793-948F-49af-A347-D19C374A7C4F:443ea8cf-8bfd-4c3e-8e1e-b0b2d137176c" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"> </div>