Search code examples
.netsilverlightwcfassembliesservice-reference

Is there a simple way to add a service reference to one assembly but keep the client config in another?


I'm aware of the drawbacks of simply adding WCF service references (later I intend to create client proxies another way), but for now I need to add a service reference to a Silverlight assembly but the config to the main UI assembly so that it will be packaged into the .xap file. Is there an easy way to do this?


Solution

  • vorrtex in the comments turns out to be right. I lost sight of that solution after a bit of experimentation. I had also forgotten to mention that I was using the xml transformation tasks in the .csproj file.

    My final solution is this:

    1. In Silverlight service client assembly, add WCF references as usual.
    2. Add a ServicesReferences.Configuration.ClientConfig for each build configuration
    3. Add before/after build transform targets in the .csproj
    4. Add as Link in the main Silverlight UI assembly.
    5. Build. The Silverlight Web assembly creates the .xap for that configuration with the right ServiceReferences.ClientConfig file.