2011-08-12 44 views
1

這是一個silverlight應用程序連接到一個wcf服務,該服務又連接到另一個wcf服務。從某些客戶端訪問時,wcf拋出錯誤

這整個應用程序都在windows 2003服務器上,既有wcf服務也有silverlight應用程序。它是silverlight,所以它可以在瀏覽器上運行。我們可以從我們的許多開發機器中的兩臺訪問/運行它。它可以在這兩臺機器上正常工作,但不能從任何其他機器或從同一臺服務器中正常工作。

它引發以下錯誤:

[Async_ExceptionOccurred] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60310.0&File=System.dll&Key=Async_ExceptionOccurred

at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at SilverlightClient.TestWCFReference.sendRequestCompletedEventArgs.get_Result() at SilverlightClient.Views.TestFormControl.sendRequestCompleted(Object sender, sendRequestCompletedEventArgs e) at SilverlightClient.TestWCFReference.Service1Client.OnsendRequestCompleted(Object state)

+0

這看起來像在客戶端的例外,它並不真正表明發生了什麼。您應該檢查服務器是否有錯誤,假設它寫入日誌或其他東西。 – CodingWithSpike

+0

它在這些2開發機器上工作的原因是這些機器上已經安裝了相同的wcf服務。它選擇本地wcf而不是服務器 – gangt

+0

,因此,基本上,silverlight應用程序根本無法訪問wcf服務。試圖提琴手無濟於事。 – gangt

回答

1

我發現這個問題,Silverlight客戶端使用從該的.xap文件clientconfig,而不是外部的一個。我不得不從項目中刪除clientconfig。

而對於EndPoint設置,我手動將這些設置添加到silverlight web項目的web.config中,將它傳遞給.js文件並從App.config中讀取它。有用。

的web.config

<appSettings> 
    <add key="serviceurl" value="http://localhost/Service/Service.svc"/> 
    </appSettings> 

default.aspx.cs

protected void Page_Load(object sender, EventArgs e) 
{ 
    InitialParams = "serviceurl=" + System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; 
} 

的Default.aspx

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> 
<!--other params go here--> 
       <param name="initParams" value="<%= InitialParams%>" /> 
</object> 

App.xaml.cs

//field 
public static string ServiceURL = ""; 

private void Application_Startup(object sender, StartupEventArgs e) 
{ 
    ServiceURL = e.InitParams["serviceurl"]; 
     this.RootVisual = new MainPage(); 
} 

MainPage.Xaml.cs

string url = App.ServiceURL; 
相關問題