What is "Either the application has not called WSAStartup, or WSAStartup failed"
- by Am1rr3zA
I develop a program which connect to a web-server through network every thing works fine until I try to use some dongle to protect my software. the dongle has network feature too and it's API work under network infrastructure. when I added the Dongle checking code to my program I got this error:
"Either the application has not called WSAStartup, or WSAStartup failed"
I don't have any idea what is going on?
I put the block of code which encounter exception here. the scenario I got the exception is I log in to the program (everything works fine) the plug out the dongle then the program stop and ask for dongle and I plug in the dongle again and try to log in bu I got exception on line
response = (HttpWebResponse)request.GetResponse();
DongleService unikey = new DongleService();
checkDongle = unikey.isConnectedNow();
if (checkDongle)
{
isPass = true;
this.username = txtbxUser.Text;
this.pass = txtbxPass.Text;
this.IP = combobxServer.Text;
string uri = @"https://" + combobxServer.Text + ":5002num_events=1";
request = (HttpWebRequest)WebRequest.Create(uri);
request.Proxy = null;
request.Credentials = new NetworkCredential(this.username, this.pass);
ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
response = (HttpWebResponse)request.GetResponse();
Properties.Settings.Default.User = txtbxUser.Text;
int index = _servers.FindIndex(p => p == combobxServer.Text);
if (index == -1)
{
_servers.Add(combobxServer.Text);
Config_Save.SaveServers(_servers);
_servers = Config_Save.LoadServers();
}
Properties.Settings.Default.Server = combobxServer.Text;
// also save the password
if (checkBox1.CheckState.ToString() == "Checked")
Properties.Settings.Default.Pass = txtbxPass.Text;
Properties.Settings.Default.settingLoginUsername = this.username;
Properties.Settings.Default.settingLoginPassword = this.pass;
Properties.Settings.Default.settingLoginPort = "5002";
Properties.Settings.Default.settingLoginIP = this.IP;
Properties.Settings.Default.isLogin = "guest";
Properties.Settings.Default.Save();
response.Close();
request.Abort();
this.isPass = true;
this.Close();
}
else
{
MessageBox.Show("Please Insert Correct Dongle!", "Dongle Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}