从 Windows Phone 8 调用时,所有 wcf 方法都返回 void [英] all wcf methods return void while calling from windows phone 8

查看:27
本文介绍了从 Windows Phone 8 调用时,所有 wcf 方法都返回 void的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的 windows phone 8 项目中添加 wcf 服务引用时,所有服务方法都返回 void ,

我已经使用了所有的 Asyn 并等待

 public async void getdata(){ServiceReference1.BALClient 服务 = new ServiceReference1.BALClient();var list=await service.Get_ListAsync("SQL");}

<块引用>

错误 错误 无法将 void 分配给隐式类型的局部变量
不能等待无效

当我使用 Asyn 并完成 eventArgs 时,它也不起作用

 public async void getdata(){service.helloAsync();service.helloCompleted += new EventHandler(service_helloCompleted);}public void service_helloCompleted(object sender, ViceReference1.helloCompletedEventArgs e){字符串 i = e.Result;}

解决方案

一些搜索和搜索我得到了解决方案

确保 webservice 有完整地址和机器 IP.

<代码>>http://localhost:6060/Web_new

生成ip地址而不是本地主机

<代码>>http://192.160.16.1:6060/Web_new

when i have add the wcf service refrence in my windows phone 8 project , all the service methods have return void ,

i have use all Asyn and await

 public async void getdata()
        {
            ServiceReference1.BALClient service = new ServiceReference1.BALClient();
            var list=await service.Get_ListAsync("SQL");      
        }

Error Error Cannot assign void to an implicitly-typed local variable
Cannot await void

and when i use Asyn and completed with eventArgs that is also not working

    public async void getdata()
      {    
            service.helloAsync();
                   service.helloCompleted += new EventHandler<ServiceReference1.helloCompletedEventArgs>(service_helloCompleted);

      }
   public void service_helloCompleted(object sender, viceReference1.helloCompletedEventArgs e)
     {
                   string i = e.Result;
     }

解决方案

some doing search and search i got the solution

make sure that webservice have full address with machine IP.

> http://localhost:6060/Web_new

make ip address instead of localhost

> http://192.160.16.1:6060/Web_new

这篇关于从 Windows Phone 8 调用时,所有 wcf 方法都返回 void的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆