Is there a slick way to deploy the silverlight application and change the settings programmatically?

I am new to web development. I am at the deployment point (for testing). I have several places (maybe 4 places) where I had to add a URI that was not relevant to the application. So now, when deployed, they need to be changed.

Is there a slick way to handle this? With slick, I do not mean going through the application manually , and changing a URI or blanket is found and replaced (too risky). I have only 4 places to change, but this can easily change and cause deployment problems.

I use the Microsoft technology stack. Silverlight, ASP.NET, RIA, etc. Development is done in Visual Studio 2010.

I noticed that web projects have a great conversion for web.config ... which is nice. Is there an equivalent mechanism for Silverlight resources? Any other ways?

Any thoughts?

+5
source share
3 answers

I just found this post on a stack overflow regarding the use of the built-in MS transformation mechanism for service references. But actually ... this is common to any XML file. This means that I was able to apply the same concepts to my custom XML file that contained some settings ... and it worked brilliantly.

See the Randoms solution. This is not a chosen solution, but it is much better than everything I've seen.

+1
source

- Silverlight - .

<object ....>
... 
<param name="initParams" value="prm1=http://google.com,prm2=http://bing.com" />
...
</object>

Silverlight (App.xaml.cs, Application_Startup):

foreach (var item in e.Initparams)
{
  this.Resources.Add(item.Key, item.Value);
}

:

var prm1 = App.Current.Resources["prm1"].ToString();
+1

This is not too pretty, but you can check what DEBUG defines (defined by default debugging mode):

#if (DEBUG)
    myUrl = "http://www.google.com";
#else
    myUrl = "http://www.bing.com";
#endif
0
source

All Articles