In programming, novice, so any advice in writing code will be greatly appreciated! I am writing a program for getting a list of friends from VK.
private void button1_Click(object sender, EventArgs e) { string email = txtlogin.Text.ToString(); string pass = txtpass.Text.ToString(); var api = new VkApi(); Settings settings = Settings.All; int appId = appid; Form2 form2; form2 = new Form2(); if (txtlogin.Text != "" || txtpass.Text != "") { try { api.Authorize(appId, email, pass, settings); } catch { MessageBox.Show("Неверный логин или пароль"); } } else { MessageBox.Show("Заполните поля", ""); } form2.Show();//открываю вторую форму после успешной авторизации this.Hide();// закрываем первую форму } As I think, and it is probably obvious that the second form does not see that the authorization has been successfully passed and you can contact VC.
The question is, how should I be? Thank!
Here is what I am writing in the second form:
var api = new VkApi(); var group = api.Utils.ResolveScreenName("etorostov"); long id = group.Id.Value; int totalCount = 1; int count = 5; var wallpost = api.Wall.Get(-id, out totalCount, count); foreach (var one in wallpost) { listBox1.Items.Add(one.Text); } Gives an error message
An unhandled exception of type 'VkNet.Exception.AccessTokenInvalidException' occurred in VkNet.dll