The main point here is the same name exception:
[ServiceContract] publicinterface iuserinfo { [ OperationContract] string showname (string name); [OperationContract] string showname (); }
For OperationContract with the same name, if the client references the service, the exception is reported as follows:
Workaround:
[ServiceContract] Public Interface Iuserinfo { [OperationContract] string showname (string name);
Set alias [OperationContract (Name= "Shownamedefault")] string showname (); }
Such a client-side reference does not report an exception, but ShowName overloads, which do not work, are referenced in detail as follows:
If you need to use ShowName with the same name, you need to customize instead of using auto-generated:
classUserinfoserviceclient:clientbase<iuserinfo>, Iuserinfo { Public stringShowName () {return This. Channel.shownamedefault (); } Public stringShowName (stringname) { return This. Channel.showname (name); } #regionIuserinfo Operation not implemented Publictask<string> Shownameasync (stringname) { Throw Newnotimplementedexception (); } Public stringShownamedefault () {Throw Newnotimplementedexception (); } Publictask<string>Shownamedefaultasync () {Throw Newnotimplementedexception (); } #endregion }
Static void Main (string[] args) { new userinfoserviceclient (); Console.WriteLine (client. ShowName ()); Console.readkey (); }
The OperationContract of WCF