3
votes

There is ServiceReferences.ClientConfig file that holds different settings of WCF services Silverlight application is using. Nice and easy, except once you set them you cannot change them later without modifying a xap.

I want to make these setting configurable with a less pain. There are several options:

  • Add a dedicated section in web.config where an administrator could change them. Transfer these settings to silverlight then rendering object on page. Parse it in silverlight, then build channel manually. Something I'd rather avoid.
  • It would be nice if we could say silverlight application to load ServiceReferences.ClientConfig not from xap resources, but from a specified uri. That way I could place this config along web.config. Nice. Not possible though.
  • If I could substitute resource stream resolver, that would work too. Sadly it doesn't seem to be possible either. There is IApplicationResourceStreamResolver, but it's internal.
  • Maybe there is a way to rewrite application resource stream after a silverlight application is started?
1

1 Answers

2
votes

I guess you want to make the servicesclient config file at the runtime.

If that is the case then simply create object of System.ServiceModel.BasicHttpBinding and assign properties and assign service URL to System.ServiceModel.EndpointAddress. This binding object and endpointaddress object can be then assigned to the client object constructor and voila!