WCF方法错误 [英] Error in wcf method

查看:113
本文介绍了WCF方法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的代码中出现以下错误:

Hi,

I am getting following error in my code:


错误:

``WcfClient.Client.ConsultationClientWCF(ref int)'':并非所有代码路径都返回值

Error:

''WcfClient.Client.ConsultationClientWCF(ref int)'': not all code paths return a value



代码



Code

public  retour ConsultationClientWCF( ref int ID_CLIENT)
  {
      Service1 ser = new Service1();
      ser.ConsultationClient(ID_CLIENT);

      if ( ser.ConsultationClient(ID_CLIENT).Equals(0)){
          retour rt = new retour();
          rt.succes = 0;
          rt.msgsucces = "opération réeussite";
          return rt;
      }

      else if (ser.ConsultationClient(ID_CLIENT).Equals(-1)){
          retour ht = new retour();
          ht.echec = -1;
          ht.msgechec = "Operation échoué";
        return ht;
      }
  }



请帮我:( :( :(:(



Pease help me :( :( :( :(

推荐答案

您需要为语句的else部分提供一个return 值.

You need to have a return value for the else part of the statement.

if ( ser.ConsultationClient(ID_CLIENT).Equals(0)){
retour rt = new retour(); 
rt.succes = 0;
rt.msgsucces = "opération réeussite";
return rt; 
}

else if (ser.ConsultationClient(ID_CLIENT).Equals(-1)){ 
retour ht = new retour();
ht.echec = -1;
ht.msgechec = "Operation échoué";
return ht; 
}
else
{
return null;//or some other value here;
}


这篇关于WCF方法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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