Click here to Skip to main content
15,559,491 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a beginner in windows phone development using C#. I have successfully connected my app to Azure but keep getting the following error whenever I click the button to save text from textboxes and a listpicker item to Azure:

Quote:
An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Error getting value from 'DisplayMemberPath' on 'MS.Internal.DisplayMemberTemplate'.


Below is my sample code. The line in bold is the one with the error:

private async void InsertUser(UsersLog user)
    {
        // This code inserts a new User into the database. 
        **await Users.InsertAsync(user);**
        users.Add(user);
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var userName = new UsersLog { Username = txtUserName.Text };
        if (MyPassword.Text == MyPassword1.Text)
        {
            var password = new UsersLog { Password = MyPassword1.Text };
            ListPickerItem selectedItem = this.lpkSecQuestion.ItemContainerGenerator.ContainerFromItem(this.lpkSecQuestion.SelectedItem) as ListPickerItem;
            var securityQ = new UsersLog { SecurityQuestion = selectedItem };
            var answer = new UsersLog { Answer = txtAnswer.Text };

            InsertUser(userName);
            InsertUser(password);
            InsertUser(securityQ);
            InsertUser(answer);

            //launch a form to register Owner (RegisterOwner.xaml)
            NavigationService.Navigate(new Uri("/RegisterOwner.xaml", UriKind.Relative));
        }
        else
        {                
            MessageBoxResult result = MessageBox.Show("The Password mismatch","User Account",MessageBoxButton.OKCancel);
            switch (result)
            {
                //User pressed OK button
                case MessageBoxResult.OK:
                    MyPassword.Text = "";
                    MyPassword1.Text = "";
                    MyPassword.Focus();
                    break;
            }               
        }

    }

Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900