A
Andy Baker
Hello. I am trying to convert my code to work with OpenNetCF 2.2, but have
run into a few problems. Firstly, to identify the WiFi card in my device, I
am using the following VB.NET code:
Dim objAdapter As WirelessZeroConfigNetworkInterface
Dim objAdapters As NetworkInterfaces() =
NetworkInterface.GetAllNetworkInterfaces
For i As Integer = 0 to objAdapters.Length - 1
If objAdapters(i).NetworkInterfaceType =
NetworkInterfaceType.Wireless80211 then
objAdapter = CType(objAdapters(i),
WirelessZeroConfigNetworkInterface)
Exit For
End if
Next
This is giving me 2 problems 1) I am getting 2 first chance exceptions
System.ComponentModel.Win32Exception occurred in OpenNETCF.dll (IOControl
call failed), and
OpenNETCF.Net.NetworkInformation.NetworkInformationException occurred in
OpenNETCF.dll. It does fill the array with 2 network adapters though (my
WiFi card and the USB connection). 2) My WiFi card is identified as
NetworkInterfaceType.Ethernet, not Wireless80211. I previously used
Networking.GetAdapters and objAdapter.IsWireless to do this job, whcih
worked OK.
Secondly, my device only ever connects to 2 networks, so I thought I
could set them both up in the preferred list and use
ConnectToPreferredNetwork to choose the one that I want to connect to. I use
PreferredAccessPoints to get the preferred list, then loop through them. If
there are access points in the preferred list that are not preferred, I use
RemovePreferredNetwork to remove them, and use AddPreferredNetwork to add
the network I want to connect to if it is not in the preferred list.
AddPreferredNetwork adds a network to the preferred list and returns true,
but both ConnectToPreferredNetwork and RemovePreferredNetwork return false,
and don't do anything. I presume an error is occurring somewhere - is there
a way of telling if this is the case? The parameter in both cases is the
SSID of the network in the preferred list, and I can connect to either
network from the windows screen successfully.
I'm sure it's something simple, but I cannot see what I am doing wrong,
or is there a better way of doing it that using the preferred list. My only
thought was that maybe the network adapter that I am using is not WZC
compatible or something, so I cannot use the
WirelessZeroConfigNetworkInterface. Any suggestions would be appreciated.
Andy Baker
run into a few problems. Firstly, to identify the WiFi card in my device, I
am using the following VB.NET code:
Dim objAdapter As WirelessZeroConfigNetworkInterface
Dim objAdapters As NetworkInterfaces() =
NetworkInterface.GetAllNetworkInterfaces
For i As Integer = 0 to objAdapters.Length - 1
If objAdapters(i).NetworkInterfaceType =
NetworkInterfaceType.Wireless80211 then
objAdapter = CType(objAdapters(i),
WirelessZeroConfigNetworkInterface)
Exit For
End if
Next
This is giving me 2 problems 1) I am getting 2 first chance exceptions
System.ComponentModel.Win32Exception occurred in OpenNETCF.dll (IOControl
call failed), and
OpenNETCF.Net.NetworkInformation.NetworkInformationException occurred in
OpenNETCF.dll. It does fill the array with 2 network adapters though (my
WiFi card and the USB connection). 2) My WiFi card is identified as
NetworkInterfaceType.Ethernet, not Wireless80211. I previously used
Networking.GetAdapters and objAdapter.IsWireless to do this job, whcih
worked OK.
Secondly, my device only ever connects to 2 networks, so I thought I
could set them both up in the preferred list and use
ConnectToPreferredNetwork to choose the one that I want to connect to. I use
PreferredAccessPoints to get the preferred list, then loop through them. If
there are access points in the preferred list that are not preferred, I use
RemovePreferredNetwork to remove them, and use AddPreferredNetwork to add
the network I want to connect to if it is not in the preferred list.
AddPreferredNetwork adds a network to the preferred list and returns true,
but both ConnectToPreferredNetwork and RemovePreferredNetwork return false,
and don't do anything. I presume an error is occurring somewhere - is there
a way of telling if this is the case? The parameter in both cases is the
SSID of the network in the preferred list, and I can connect to either
network from the windows screen successfully.
I'm sure it's something simple, but I cannot see what I am doing wrong,
or is there a better way of doing it that using the preferred list. My only
thought was that maybe the network adapter that I am using is not WZC
compatible or something, so I cannot use the
WirelessZeroConfigNetworkInterface. Any suggestions would be appreciated.
Andy Baker