の位置から計算されます。
WebアプリケーションのWeb.configで、AppSettingsに変数を追加し、ベースURLを保存します。これは、SVCファイルの場所が格納されていないことに注意してください。これは、私が通常指し示す複数のSVCがあるためです。あなたはそれを違うように選ぶかもしれません。私のWebアプリケーションのWebページで
<appSettings>
<add key="ServiceURI" value="http://localhost:64457/"/>
</appSettings>
、PARAMを追加InitParmsと呼ばれ、これは、キーのリストを追加することができ、ペア値(XAPファイルによって読み込まれるカンマで区切られた)
<div id="silverlightControlHost">
<object data="data:application/x-silverlight," type="application/x-silverlight-2"
width="100%" height="100%" ID="Xaml1" >
<param name="InitParams" value="ServiceURI=<%= ConfigurationManager.AppSettings("ServiceURI") %>" />
SilverlightのApp.xaml.vbで
は、リソースにすべてのInitParmsを読み込むか、どこが私のXAMLファイルのいずれかでその後
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
をしたい、これまで私が設定されたURIを使用してサービスを初期化することができ、私は午前を持っていますこの
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 & "svc/secure/Service.svc"
_client = New ServiceClient("CustomBinding_Service", New EndpointAddress(uri_withservice))
End If
End Sub
この解決策は私が心配する限り最高です。他のハードコーディングされた解決策は私のためには機能しません。 – helios456