What's wrong with the app?

Good time of day. Trying to write a simple app (especially on video), but gives an error
An unhandled exception of type "System.TypeLoadException" in VkNet.exe

Additional information: could Not load type "VkNet.VkApi" from Assembly "VkNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".


Code looks like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VkNet;
using VkNet.Enums.Filters;

namespace VkNet
{
 public partial class Form1 : Form
{
 VkApi vkApi = new VkApi();

 public Form1()
{
InitializeComponent();
}

 private void label1_Click(object sender, EventArgs e)
{

}

 private void Form1_Load(object sender, EventArgs e)
{

}

 private void button1_Click(object sender, EventArgs e)
{
 int appID = 5974922;
 string email = File.ReadAllText(@"D:\email.txt");
 string password = File.ReadAllText(@"D:\password.txt");
 Settings settings = Settings.All;
 vkApi.Authorize(appID, email, password, settings);
The GetFriends();

}

 public void GetFriends()
{
 var users = vkApi.Friends.Get(173938201, ProfileFields.FirstName | ProfileFields.LastName);
 foreach(var friend in users)
{
 ListFriends.Items.Add(friend.FirstName + "" + friend.LastName);
}
}

 private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}

The project itself is here: rgho.st/6c2QvXhkW
Help, I don't know where to dig.
June 27th 19 at 14:51
1 answer
June 27th 19 at 14:53
Solution
I vaguely understand what to offer, but after the manipulations below should work.

1) Go to https://vknet.github.io download the library vknet as a zip file and unpack

2) Copy the entire project (may not need entire, XS) in the folder of your project (approximately prntscr.com/eusnut (I copied inside the folder test)

3) Open your project

4) In solution Explorer, Add existing project prntscr.com/eusokj

5) Choose VkNet.UWP.csproj (she's inside \test\VkNet.UWP)

6) Next in the Assembly prntscr.com/euspa2

7) Next add the link prntscr.com/euspi6 prntscr.com/euspqh

8) Remove the old link prntscr.com/eusq1b

9) Go here https://vk.com/editapp?act=create and create a new Standalone application

10) Profit prntscr.com/eusr3i

11) Change methods a little bit

private void button1_Click(object sender, EventArgs e)
{
 int appID = 123456;
 string email = "login";
 string password = "pass";
 Settings settings = Settings.All;

 vkApi.Authorize( new ApiAuthParams {
 ApplicationId = (ulong)appID
 Login = email,
 Password = password,
 Settings = settings
});
 if (vkApi.IsAuthorized)
{
MessageBox.Show(vkApi.UserId.ToString());
}
The GetFriends();

}

 public void GetFriends()
{
 ProfileFields pf = ProfileFields.FirstName | ProfileFields.LastName;
 var users = vkApi.Friends.Get(FriendsGetParams new { UserId = vkApi.UserId, Fields = pf, Count=10 });
 foreach (var friend in users)
{
 ListFriends.Items.Add(friend.FirstName + "" + friend.LastName);
}
 }
Thank you, the decision noted, however it is still this code doesn't run (something really terrible came up with the code itself). Can't throw your project, by chance? - Christian.Thi commented on June 27th 19 at 14:56
UPD. My mistake, figured it out.
However, when clicking on login, you still get the error prntscr.com/ew14kj - Christian.Thi commented on June 27th 19 at 14:59
: changed application type on the website of the VC? - marilou.Hodkiewicz21 commented on June 27th 19 at 15:02
: it has been the SA, and left. - Christian.Thi commented on June 27th 19 at 15:05

Find more questions by tags C#