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

  • SEARCH
  • Home
  • 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 1033841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:17:41+00:00 2026-05-16T14:17:41+00:00

I am developing a silverlight 4.0 application which communicates with a WCF service. The

  • 0

I am developing a silverlight 4.0 application which communicates with a WCF service.

The WCF configuration (endpoint, …) is contained in the ServiceReferences.ClientConfig file.

However, I would like the silverlight application to get this config from the web server as I don’t want to recompile the application or fiddle with the XAP file (I know it’s a zip file) since the users are only allowed to configure the web server and this config would be different per server/site.

Is there a way for a silverlight application to receive some kind of info from the web server or to get such data from it?

  • 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-16T14:17:42+00:00Added an answer on May 16, 2026 at 2:17 pm

    Ok, after much searching around the net I was able to code the following solution by aggregating the different pieces of information I found.

    First, Silverlight 4 (like SL3) use a different mechanism for creating the silverlight control in the web page on the client. It uses the < object > tag.

    To pass initialization parameters to a silverlight application you just need to add

    <param name="initParams" value="key1=value1,key2=value2" />
    

    to the page.aspx file (from the web project) under the object tag and the SL app will receive those 2 parameters at startup.

    For example, using the default aspx page generated from VS2010:

    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
        <param name="source" value="ClientBin/MyApp.xap"/>
        <param name="onError" value="onSilverlightError" />
        <param name="background" value="white" />
        <param name="minRuntimeVersion" value="4.0.50401.0" />
        <param name="autoUpgrade" value="true" />
        <param name="initParams" value="key1=value1,key2=value2" />
        <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
            <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
        </a>
    </object>
    

    To access the parameters in the SL app, you just have to code the following in the App.xaml.cs file:

    private void Application_Startup(object sender, StartupEventArgs e)
    {
        var builder = new StringBuilder ();
    
        foreach (String key in e.InitParams.Keys)
            builder.AppendFormat ("from InitParams: {0} = {1}", 
                                  key, e.InitParams[key]).AppendLine ();
    
        HtmlPage.Window.Alert (builder.ToString ());
    
        // Other code...
    }
    

    For now, this only allows static values for the parameters.
    To have dynamic values you just have to change the initParam line to:

    <param name="initParams" value="<%= string.Format("WCFReferenceURL={0}", ConfigurationManager.AppSettings["WCFReferenceURL"])%>" />
    

    to get the values from the configuration file on the web server. 😉

    I hope this helps some poor soul out there!

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

Sidebar

Related Questions

I am developing Silverlight application with Prism 4 and WCF RIA service. I had
I'm developing a Silverlight Business Application, using a RIA service, which is returning POCO
I'm developing a Silverlight 3 Application which I want to connect to a webservice
I am developing an silverlight application using WCF and EF. I am using Database
I am developing a Silverlight 3 application and I would like to delegate all
I am developing a Silverlight application which has a list <ListBox x:Name=_list_collection SelectionChanged=SelectionChanged ScrollViewer.VerticalScrollBarVisibility=Auto
We are currently developing a web application in ASP.NET MVC which would really benefit
What is the correct pattern or method for developing a Silverlight application (which is
I'me currently developing a silverlight application. In this application, I've an exception handler which
hi im developing silverlight application but when i m trying to compile that file

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.