我创建了用于检查用户名、密码的 WCF Web 服务,并使用 MYSQL 数据库检查用户名和密码是否存在。我在 WP7 中创建了带有用户名、密码和登录按钮的两个文本框的应用程序。当我运行应用程序时,会发生“KeyNotFoundException”。请告诉我原因。
my code is here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using consumeWCFwp7DB.ServiceReference1;
namespace consumeWCFwp7DB
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void btnadd(object sender, RoutedEventArgs e)
{
ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient();
string username = txtusername.Text.ToString();
string password = txtpassword.Text.ToString();
obj.loginAsync(username, password);
obj.loginCompleted+=new EventHandler<loginCompletedEventArgs> (obj_loginCompleted);
}
void obj_loginCompleted(object sender, loginCompletedEventArgs e)
{
if (e.Error == null)
{
MessageBox.Show(e.ToString());
}
else
{
MessageBox.Show("Error");
}
}
}
}