The problem with the connection to a WiFi modem in C#?

In General, doing laboratory work at the University, a program for Windows, with a search of the Internet and a further connection to him, finds the network, connects, but when it comes connection, tethering to the phone (a La iPhone (Alexander)) the program stops to run the script ( pointless click on the connect button and nothing happens ). Thanks to all who respond
help me!

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NativeWifi;
using SimpleWifi;

namespace IvanovMRLab2
{
 public partial class Form1 : Form
{
 private static Wifi;
 List<AccessPoint> aps;

 public Form1()
{
InitializeComponent();
}

 private void btnRefresh_Click(object sender, EventArgs e)
{
 buttonCON.Enabled = false;
listNet.Items.Clear();
comboBox1.Items.Clear();
 wifi = new Wifi();

 aps = Wi-Fi.GetAccessPoints();

 WlanClient client = new WlanClient();
 foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
{
 Wlan.WlanAvailableNetwork[] wlanBssEntries = wlanIface.GetAvailableNetworkList(0);
listNet.Items.Clear();
 foreach (Wlan.WlanAvailableNetwork network in wlanBssEntries)
 { 
 ListItemWifi ListViewItem = new ListViewItem();
 listItemWifi.Text = System.Text.Encoding.UTF8.GetString(network.dot11Ssid.SSID).Trim((char)0);
 listItemWifi.SubItems.Add(network.wlanSignalQuality.ToString() + "%");
listItemWifi.SubItems.Add(network.dot11DefaultAuthAlgorithm.ToString().Trim((char)0));
listItemWifi.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString().Trim((char)0));
 listItemWifi.ImageIndex = 0;
listNet.Items.Add(listItemWifi);
comboBox1.Items.Add(listItemWifi.Text);

}
}

 lbl_Status.Visible = true;
 comboBox1.Visible = true;
 textBox1.Visible = true;
 buttonCON.Visible = true;
}

 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
 buttonCON.Enabled = true;
}

 private void buttonCF_Click(object sender, EventArgs e)
{
 if (wifi.ConnectionStatus == WifiStatus.Connected)
{
Wi-Fi access.Disconnect();
 lbl_Status.Text = "Connection closed.";
}
}

 private bool connectToWifi(AccessPoint ap, string password)
{
 AuthRequest authRequest = new AuthRequest(ap);
 authRequest.Password = password;
 return ap.Connect(authRequest);
}

 private void buttonCON_Click(object sender, EventArgs e)
{
 if (comboBox1.SelectedIndex >= 0)
{
 foreach (AccessPoint ap in aps)
{
 if (comboBox1.SelectedItem.ToString() == ap.Name)
{
 if (ap.IsSecure)
{
 if (textBox1.Text.Length > 7)
{
 if (connectToWifi(ap, textBox1.Text))
{
 lbl_Status.Text = "Connection successful.";
 buttonCF.Visible = true;
 buttonCF.Enabled = true;
}
else
 lbl_Status.Text = "failed to connect.";
}
else
 lbl_Status.Text = "Enter password ( =< 8 characters)";
}
else
{
 if (connectToWifi(ap, "12345678"))
{
 lbl_Status.Text = "Connection successful.";
 buttonCF.Visible = true;
 buttonCF.Enabled = true;
}
else
 lbl_Status.Text = "failed to connect.";
}
}
}
}
else
 lbl_Status.Text = "Select a network to connect to.";
}

 private void listNet_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
}
March 19th 20 at 08:43
1 answer
March 19th 20 at 08:45
Now we get ready for libastral.so and see your code. Wait for an hour.
Well, or I can put the code on Pastebin and speed up the process :)

Find more questions by tags C#