我們正在構建Silverlight應用程序並調用Silverlight-WCF服務。從Visual Studio運行應用程序時,一切正常。當我們部署到網站並運行應用程序時,每次調用Web服務時都會收到以下錯誤(或者非常喜歡它)。Silverlight webservice調用在Studio中工作,但在從網站運行時失敗
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SSS.MVVMCore.Silverlight.WebPortalService.GetThemeIdCompletedEventArgs.get_Result()
at SSS.MVVMCore.Silverlight.ViewModels.StandardBaseFrameViewModel.<.ctor>b__0(Object s, GetThemeIdCompletedEventArgs ea)
at SSS.MVVMCore.Silverlight.WebPortalService.WebPortalServiceClient.OnGetThemeIdCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://ssswebportal.com/login.aspx?p=d53ae99b-06a0-4ba7-81ed-4556adc532b2
基於他的消息,該服務被稱爲完全執行,但是,當它試圖反序列化的結果早在Silverlight應用程序出現錯誤。對於正在發生的事情以及我們可以採取哪些措施來解決問題有任何建議?
< < < < < < < < < < < < < < < < < < < < < < < < < < < <跟進>>>>>>>>>>>>>>> >>>>>>>>>>>>>
這是我們的決議:
在ServiceReferences.ClientConfig文件,我們有下面的代碼:
<client>
<endpoint address="http://localhost:5482/WebPortalService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_WebPortalService"
contract="WebPortalService.WebPortalService" name="CustomBinding_WebPortalService" />
</client>
注意 'localhost' 的線。它在發佈時需要成爲我們的Web服務器地址,但在開發時需要成爲本地主機。
人對如何自動完成這個任何建議,讓我們沒有之前手動更改此行每發佈嗎?
您應該能夠通過傳遞的EndpointAddress並沒有回答關於ServiceReferences.ClientConfig設置的配置對象綁定到在代碼中創建您的服務代理。也許你可以自己管理端點的配置,並使用某種#if DEBUG替換localhost。 – 2011-02-24 17:49:41