Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There may be better ways, which I'm open to using but this works for me and it's flexible.</p> <p>In your Web Application's <strong>Web.config</strong>, add a variable in AppSettings and store the base URL, notice that I'm not storing the location of the SVC file, I will append that later. This is because I have multiple SVC that I usually point to. You may choose to do it differently.</p> <pre><code> &lt;appSettings&gt; &lt;add key="ServiceURI" value="http://localhost:64457/"/&gt; &lt;/appSettings&gt; </code></pre> <p>In my Web Application's Web Page, add a param called InitParms, this allows you to add a list of key, pair values (seperated by comma that will be read by the XAP file)</p> <pre><code>&lt;div id="silverlightControlHost"&gt; &lt;object data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%" ID="Xaml1" &gt; &lt;param name="InitParams" value="ServiceURI=&lt;%= ConfigurationManager.AppSettings("ServiceURI") %&gt;" /&gt; </code></pre> <p>In the Silverlight App.xaml.vb, load all the InitParms into a Resource or where ever you want</p> <pre><code> Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup If e.InitParams IsNot Nothing Then For Each k As Generic.KeyValuePair(Of String, String) In e.InitParams Me.Resources.Add(k.Key, k.Value) Next End If </code></pre> <p>Then in any of my XAML files I can initialize the service with the configured URI, I have a method like this</p> <pre><code>Private Sub InitializeService() Dim uri As String = App.Current.Resources("ServiceURI") If uri Is Nothing OrElse uri = String.Empty Then 'if there is no value added in the web.config, I can fallback to default values _client = New ServiceClient Else 'Notice I hardcoded the location of the SVC files in the client and append there here, you may choose not to do this Dim uri_withservice As String = uri &amp; "svc/secure/Service.svc" _client = New ServiceClient("CustomBinding_Service", New EndpointAddress(uri_withservice)) End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload