user-editable XML config file for silverlight OOB app

Requirement: user-editable XML config file (like app.config or yourAppName.config) to control my silverlight OOB app.

Solution: Here are the key steps based on http://www.mohamedibrahim.net/blog/2010/01/27/creating-and-using-silverlight-app-settings-webconfig-configuration-applicatioin-settings-to-change-wcf-service-address-after-deployment-servicereferencesclientconfig-servicereferences-clientconfig/

1) move your app.config content into ServiceReferences.ClientConfig. This file is editable post-install, unlike the app.config which gets converted to binary and embedded in the DLL during build-deploy.

The blog above describes how to pragmatically parse the xml config — nothing fancy.

2) After the install (using sllauncher), you can easily locate the xap file. On my winXP PC it’s in C:\Documents and Settings\myLogin\Local Settings\Application Data\Microsoft\Silverlight\OutOfBrowser\1352946853.theOriginHostname

C:\Users\a5113359\AppData\Local\Microsoft\Silverlight\OutOfBrowser on my win7.

As you would expect, this xap gets overwritten whenever you re-install (with sllauncher). This is one way to confirm any code change took effect.

3) edit the ServiceReferences.ClientConfig file inside the xap. The blog above describes the technique. Actually no need to rename. Just use 7z to open the xap.

4) restart the OOB app. See new config value.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s