Question

I'm developing an n-tier smart client application. The client part of the application is split into two tiers. An interface application and client business lib that retrieves and serves data to the interface. The data is supplied via a collection of WCF services net.tcp and http depending on the client connectivity.

My problem is that the interface knows nothing of the wcf services (as we want) the configurations system.serviceModel binding info is stored within the config for the lib rather than the exe. Unless I copy the system.serviceModel section to the exe config the application cannot find the endpoints.

So I could create some Pre-Build event that copies the app.config file:

attrib -r "$(ProjectDir)app.config" copy "$(SolutionDir)Domain\Client\app.config" "$(ProjectDir)"

but this, frankly, is crap (its a straight copy not merge) and I want a better way of working it.... Any ideas? Thanks

Was it helpful?

Solution

Have you tried importing the relevant sections from an external config file using the configSource element? The last answer in this discussion provides a solution that may work for you.

Quoted from that discussion:

<!-- WCF Configuration Mappings in app.config -->
<system.serviceModel>
  <bindings configSource=".\CommonConfig\ServiceBindings.config" />
  <client configSource=".\CommonConfig\ServiceClient.config" />
</system.serviceModel>

ServiceBindings.config:

<?xml version="1.0" encoding="utf-8" ?>
<bindings>
  <netTcpBinding>
    <binding ... />
  </netTcpBinding>
</bindings>

ServiceClient.config (shortened):

<?xml version="1.0" encoding="utf-8" ?>
<client>
  <endpoint ...>
      ...
  </endpoint>
</client>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top