我创建了一个WCF,然后我创建了一个WP8应用程序并添加了服务引用。错误是"类型&System; Service.ServiceModel.FaultException'发生在System.ServiceModel.ni.dll中,但未在用户代码"
中处理如果有人能够给我一些指示,因为我用谷歌搜索了这个并发现没有相同的东西。
错误出现在这里
public void EndAddUser(System.IAsyncResult result)
{
object[] _args = new object[0];
base.EndInvoke("AddUser", _args, result);
}
我的主要课程:
public partial class MainPage : PhoneApplicationPage
{
private Service1Client _serviceClient;
// Constructor
public MainPage()
{
InitializeComponent();
_serviceClient = new Service1Client();
_serviceClient.LoginUserCompleted += new
}
private void loginBtn_Click(object sender, RoutedEventArgs e)
{
_serviceClient.LoginUserAsync(userNameTxtBox.Text, passwordTxtBox.Text);
}
private void newAccountBtn_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("/AddAccount.xaml", UriKind.Relative));
}
private void _serviceClient_LoginUserCompleted(object senter,
LoginUserCompletedEventArgs e)
{
if (e.Error == null && e.Result != null)
{
MessageBox.Show("Welcome " + e.Result + "!");
}
else
{
MessageBox.Show("Could not log in. Please check user name/password and try
again.");
}
}
}
public partial class AddAccount : PhoneApplicationPage
{
private Service1Client _serviceClient;
public AddAccount()
{
InitializeComponent();
_serviceClient = new Service1Client();
_serviceClient.AddUserCompleted += new EventHandler<AsyncCompletedEventArgs>
(_serviceClient_AddUserCompleted);
}
private void addAccountBtn_Click(object sender, RoutedEventArgs e)
{
_serviceClient.AddUserAsync(fullnameTxtBox.Text, userNameTxtBox.Text,
passwordTxtBox.Text);
}
void _serviceClient_AddUserCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
MessageBox.Show("User account created. Please login");
this.NavigationService.GoBack();
}
else
{
MessageBox.Show("User account could not be added, Please try again");
}
}
}