[英]Deployed Silverlight application exception when calling a WCF Service
silverlight應用程序運行,但是當調用服務時,我得到:
操作期間發生異常,使結果無效。 檢查InnerException以獲取異常詳細信息。 在SalesSimplicityPO_SL.POSvc.GetPurchaseOrdersCompletedEventArgs.get_Result()在System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()在SalesSimplicityPO_SL.About.mySvc_GetPurchaseOrdersCompleted(Object sender,GetPurchaseOrdersCOMleted
我加載並調用我的Web服務,例如。
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));
POSvc.POSvcClient mySvc = new POSvc.POSvcClient(binding, address);
mySvc.InsertPOCompleted += new EventHandler<SalesSimplicityPO_SL.POSvc.InsertPOCompletedEventArgs>(mySvc_InsertPOCompleted);
mySvc.InsertPOAsync(InitialsTextBox.Text.ToString(), DescTextBox.Text.ToString(), ClientTextBox.Text.ToString());
在調試時效果很好。
我要怎么做才能得到這個錯誤?
更新:
我真的不太明白為什么要修復它,但是可以解決。.也許有人可以提供一些信息...
我變了
EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));
至
EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc"));
之所以可行,是因為silverlight不能像ASP.NET一樣解析虛擬路徑。 要轉到根ASP.NET文件夾,必須使用Application.Current.Host.Source
我真的不太明白為什么要修復它,但是可以解決。.也許有人可以提供一些信息...
我變了
EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));
至
EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc"));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.