Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6775439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:54:25+00:00 2026-05-26T15:54:25+00:00

When building an app, it is often deployed in different environments (test, dev, prod),

  • 0

When building an app, it is often deployed in different environments (test, dev, prod), and therefore the endpoint addresses are changing. As the ServiceReferences.ClientConfig is built as a part of Silverlight’s .xap file, its hard to change the endpoints after building the solution, as often is done with web.config.

I’ve searched quite a bit for it, but I cant figure out what is best practice here, so my question is:

What is best practice when it comes to dynamic wcf endpoint address configuration in silverlight?

To clarify, depending on which server the app is on (test,dev, prod) the endpoints change:

  <endpoint
    name="MyService"
    address="http://testserv/MyService.svc"
    binding="basicHttpBinding"
    bindingConfiguration="MybasicHttpBinding"
    contract="MyApp.MyService"
             />

  <endpoint
    name="MyService"
    address="http://prodserv/MyService.svc"
    binding="basicHttpBinding"
    bindingConfiguration="MybasicHttpBinding"
    contract="MyApp.MyService"
             />

In some way, i need the silverlight client to know which one to use, depending on which server its on / which build is compiled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:54:25+00:00Added an answer on May 26, 2026 at 3:54 pm

    After reading sLedgem’s post, and some googling, I found the perfect solution to make ServiceReferences act like web.config.

    First off:
    Create the different files manually;

    ServiceReferences.Debug.ClientConfig
    ServiceReferences.Release.ClientConfig
    

    You can add your own as well if you have more than the two default configurations in Visual Studio.

    Second:
    Add the file dependency in the Project.csproj file (Open the project file in a text editor):

      <ItemGroup>
        <None Include="Properties\AppManifest.xml" />
        <Content Include="ServiceReferences.ClientConfig">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="ServiceReferences.Debug.ClientConfig">
          <DependentUpon>ServiceReferences.ClientConfig</DependentUpon>
        </Content >
        <Content Include="ServiceReferences.Release.ClientConfig">
          <DependentUpon>ServiceReferences.ClientConfig</DependentUpon>
        </Content >
      </ItemGroup>
    

    Now, when you reload the project, you will see that ServiceReferences.Release.ClientConfig is expandable in the Solution Explorer, and when you expand it, you will see the Release and Debug file.

    Third: Add the Transformation rules to the Project file just before the closing </Project>

    (again, open it in a text editor)

    <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
      Other similar extension points exist, see Microsoft.Common.targets.   -->
    <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
    <Target Name="AfterCompile" Condition="exists('ServiceReferences.$(Configuration).ClientConfig')">
      <!-- Generate transformed ServiceReferences config in the intermediate directory -->
      <TransformXml Source="ServiceReferences.ClientConfig" Destination="$(IntermediateOutputPath)$(TargetFileName).ClientConfig" Transform="ServiceReferences.$(Configuration).ClientConfig" />
      <!-- Force build process to use the transformed configuration file from now on. -->
      <ItemGroup>
        <ServiceReferencesConfigWithTargetPath Remove="ServiceReferences.ClientConfig" />
        <ServiceReferencesConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).ClientConfig">
          <TargetPath>$(TargetFileName).ClientConfig</TargetPath>
        </ServiceReferencesConfigWithTargetPath>
      </ItemGroup>
    </Target>
    

    What it does is to look in the corresponding servicereferences file, depending on your configuration, and copy / replace code using the same TransformXML library that web.config uses.

    Example:

    in my ServiceReferences.ClientConfig i have the following code:

      <endpoint name="ICatalogueService" 
                address="address" 
                binding="basicHttpBinding"
                bindingConfiguration="My_basicHttpBinding" 
                contract="Services.ServiceInterfaces.ICatalogueService"/>
    

    ServiceReferences.Release.ClientConfig:

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <system.serviceModel>
        <client>
          <endpoint
            name="ICatalogueService"       
            address="http://server/Services/CatalogueService.svc"
            binding="basicHttpBinding"
            bindingConfiguration="My_basicHttpBinding"
            contract="Services.ServiceInterfaces.ICatalogueService"
            xdt:Transform="Replace" xdt:Locator="Match(name)" />
        </client>
        <extensions />
      </system.serviceModel>
    </configuration>
    

    As you can see, the endpoint will be replaced, and the match is done on the name attribute.

    If you have any questions, let me know 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an app with several languages. test.com/ -english index test.com/ca - canadian english
I'm building an app that authors would (hopefully) use to help them, uh.. author
We're building an app that stores hours of operation for various businesses. What is
I am building an app that talks to an Access database via OleDB/Jet. There
I'm building an app in Ruby on Rails, and I'm including 3 of my
So I'm building an app that uses win32's SendMessage as IPC. I'm using FindWindow
I'm building a app that need manage money datatype. I'm new on Obj-c, so
I'm building an app that pulls data in from an excel .csv file and
I'm building an app in PHP and I'm using the data mapper pattern for
I'm building a app that needs to perform calculations on money. I wonder how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.