user2060389
user2060389

Reputation: 5

system.servicemodel.communicationexception. in system.servicemodel.ni.dll

I am facing this error when I am invoking WCF services in my windows phone application. Please suggest some solution for the same.

sample code:

   private void Button_Click_1(object sender, RoutedEventArgs e)
   {

       ServiceReference1.ServiceClient myService = new ServiceReference1.ServiceClient();
       if (txtUser.Text.ToString() != null)
       {


           myService.ValidateAsync(txtUser.Text.ToString(), pwdPassword.ToString());
           System.Threading.Thread.Sleep(TimeSpan.FromSeconds(20));
           myService.ValidateCompleted += new EventHandler<ServiceReference1.ValidateCompletedEventArgs>(myService_ValidateCompleted);
       }
       else
       {
           MessageBox.Show("Enter some username or password");
       }
   }

** control is not going to next function showing:

system.servicemodel.communicationexception in System.ServiceModel.ni.dll


   private void myService_ValidateCompleted(object sender, ServiceReference1.ValidateCompletedEventArgs e)
   {

       //int a = 0;
       //a = Convert.ToInt32(e.Result);

       if (e.Result== 1)
       {
           MessageBox.Show("Enter");
           // this.NavigationService.Navigate(new Uri("/TilesPage.xaml", UriKind.Relative));
       }
       else if (e.Result == 0)
       {
           MessageBox.Show("Invalid Username or Password");
       }
       else if (e.Result == -1)
       {
           MessageBox.Show("UserName doesn't exists");
       }
       else
       {
           MessageBox.Show("some exception");
       }


   }

Upvotes: 0

Views: 2663

Answers (1)

user2136053
user2136053

Reputation:

include a catch block

catch (CommunicationException commProblem)
{
     Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace);
     Console.Read();     
}

Upvotes: 1

Related Questions