开发者

Deployed Silverlight application exception when calling a WCF Service

开发者 https://www.devze.com 2022-12-24 12:46 出处:网络
The silverlight application runs but when it calls the service I get: An exception开发者_如何学Go occurred during the operation, making the result invalid.Check InnerException for exception details.

The silverlight application runs but when it calls the service I get:

An exception开发者_如何学Go occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at SalesSimplicityPO_SL.POSvc.GetPurchaseOrdersCompletedEventArgs.get_Result() at SalesSimplicityPO_SL.About.mySvc_GetPurchaseOrdersCompleted(Object sender, GetPurchaseOrdersCompletedEventArgs e) at SalesSimplicityPO_SL.POSvc.POSvcClient.OnGetPurchaseOrdersCompleted(Object state)

I load and call my web service like..

    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());

Works great in debug....

What am I doing wrong to get this error?


Update:

I don't really understand Why it fixed it but this fixed it.. Maybe someone can offer some info...

I changed

EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));  

TO

 EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc")); 


This works because silverlight does not resolve virtual path as ASP.NET does. To go to the root ASP.NET folder you have to use Application.Current.Host.Source


I don't really understand Why it fixed it but this fixed it.. Maybe someone can offer some info...

I changed

EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));  

TO

 EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc")); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号