Demo Cloud

Demo Cloud

  • 1.9k
  • 69
  • 637

Getting an error while consuming WCF Web service reference

Apr 30 2020 9:48 PM
Hello Sir,
I'm using below llink to create and consume a WCF webservice in Xamarin forms(cross platform), but I'm getting a error show below.
 
Severity Code Description Project File Line Suppression State
Error CS1061 'Task >' does not contain a definition for 'ToList' and no accessible extension method 'ToList' accepting a first argument of type 'Task >' could be found (are you missing a using directive or an assembly reference?) LoginForm C:\Users\test\source\repos\LoginForm\LoginForm\LoginForm\MainPage.xaml.cs 26 Active
 The data type selected while calling a web service was "System.Collections.Generic.List" for Collection type and for Dictionary collection type it was by default "System.Collections.Generic.Dictionary".
 
Below is the  code which im using in MainPage.Xaml.cs
private void BtnLogin_Clicked(object sender, EventArgs e)
{
try
{
UserDetails userinfo = new UserDetails();
userinfo.UserName = usernameEntry.Text;
userinfo.Password = passwordEntry.Text;
List msg = obj.LoginUserDetailsAsync(userinfo).ToList();
messageLabel.Text = "Employee Name = " + msg.ElementAt(0) + " Employee Id = " + msg.ElementAt(1);
}
catch (Exception ex)
{
messageLabel.Text = "Wrong Id Or Password";
}
}
 
Error is displayed on ToList().
 
Please help me 
Thanks in advance 
 

Brought to you by:

Answers (16)