private void GetUser() { //连接服务端 EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "/DBService.svc")); //建立客户端对象 DBServiceClient client = new DBServiceClient(new BasicHttpBinding(), address); //添加处理事件 client.GetUserCompleted += new EventHandler<GetUserCompletedEventArgs>(client_GetUserCompleted); //传入参数 client.GetUserAsync(txtUsername.Text, pbPassword.Password); }