OpenNetCF 2.2 changes

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
 
G

Guest

Just go with something simple:

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
if (o is WirelessZeroConfigNetworkInterface)
{
....
}
}

or

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
WirelessZeroConfigNetworkInterface wzc = o as
WirelessZeroConfigNetworkInterface;
if(wzc != null)
{
....
}
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
A

Andy Baker

Thanks Chris, that recognises the card as a wzc network interface. Could you
just clarify what some of the other methods are supposed to do. The way that
I am hoping for it to work is that when I start the application, I set up
the preferred list of networks and then connect to the appropriate one as
and when I want to. As one of the 'networks' is a printer, it is possible
that if the printer is changed, the SSID of the printer will change, so I
could end up with several printers in the preferred list. For this reason I
want to remove any old ones from the preferred list. I am using
PreferredAccessPoints to get the current list, then RemovePreferredNetwork
to remove ones that I don't need any more - but RemovePreferredNetwork
always returns false, and doesn't remove any networks.
I am then using AddPreferredNetwork to add networks that are not in the
preferred list but I do need. This adds the required network (and returns
true), but it also seems to remove anything already in the preferred list -
if I have my WAP set up in the preferred list, then add the printer from
code, when I look at the preferred list afterwards, it just contains the
printer. Is this how it is supposed to work, or am I doing something wrong?
Then, I want to use ConnectToPreferredNetwork to connect to the network
that I want to use. If I only have one network in the preferred list, it
obviously connects to it automatically (if it is there), but if I have both
in the preferred list I am trying to use ConnectToPreferredNetwork to switch
to the other one, but it doesn't do it, and returns false.
Finally, as a test for whether I am conncted or not, I am checking the
IP address, and if it returns 0.0.0.0, I assume that I am not connected.
However, CurrentIPAddress sometimes returns 0.0.0.0 even when I am
connected, and can ping the network that I am connected to. Why should it do
this, and is there a better test for connectivity?
Thanks for all your help.

Andy Baker
 
G

Guest

I'm on the road all this week so I have no way to test the code or put
together a sample (I didn't bring any WinMo devices with me). Your best bet
at this point is to send an email to (e-mail address removed) with this same
info and we'll see what we can figure out, but I tested this stuff fairly
heavily back when I rewrote it (though with a very limited set of hardware).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
A

Andy Baker

OK, I'll do that - thanks.

Andy Baker

I'm on the road all this week so I have no way to test the code or put
together a sample (I didn't bring any WinMo devices with me). Your best
bet at this point is to send an email to (e-mail address removed) with this
same info and we'll see what we can figure out, but I tested this stuff
fairly heavily back when I rewrote it (though with a very limited set of
hardware).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
A

Andy Baker

Hi Chris

Any more news on this since I sent my code to (e-mail address removed)? Thanks.

Andy Baker

Andy Baker said:
OK, I'll do that - thanks.

Andy Baker

I'm on the road all this week so I have no way to test the code or put
together a sample (I didn't bring any WinMo devices with me). Your best
bet at this point is to send an email to (e-mail address removed) with this
same info and we'll see what we can figure out, but I tested this stuff
fairly heavily back when I rewrote it (though with a very limited set of
hardware).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


Andy Baker said:
Thanks Chris, that recognises the card as a wzc network interface. Could
you just clarify what some of the other methods are supposed to do. The
way that I am hoping for it to work is that when I start the
application, I set up the preferred list of networks and then connect to
the appropriate one as and when I want to. As one of the 'networks' is a
printer, it is possible that if the printer is changed, the SSID of the
printer will change, so I could end up with several printers in the
preferred list. For this reason I want to remove any old ones from the
preferred list. I am using PreferredAccessPoints to get the current
list, then RemovePreferredNetwork to remove ones that I don't need any
more - but RemovePreferredNetwork always returns false, and doesn't
remove any networks.
I am then using AddPreferredNetwork to add networks that are not in
the preferred list but I do need. This adds the required network (and
returns true), but it also seems to remove anything already in the
preferred list - if I have my WAP set up in the preferred list, then add
the printer from code, when I look at the preferred list afterwards, it
just contains the printer. Is this how it is supposed to work, or am I
doing something wrong?
Then, I want to use ConnectToPreferredNetwork to connect to the
network that I want to use. If I only have one network in the preferred
list, it obviously connects to it automatically (if it is there), but if
I have both in the preferred list I am trying to use
ConnectToPreferredNetwork to switch to the other one, but it doesn't do
it, and returns false.
Finally, as a test for whether I am conncted or not, I am checking
the IP address, and if it returns 0.0.0.0, I assume that I am not
connected. However, CurrentIPAddress sometimes returns 0.0.0.0 even when
I am connected, and can ping the network that I am connected to. Why
should it do this, and is there a better test for connectivity?
Thanks for all your help.

Andy Baker

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
Just go with something simple:

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
if (o is WirelessZeroConfigNetworkInterface)
{
....
}
}

or

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
WirelessZeroConfigNetworkInterface wzc = o as
WirelessZeroConfigNetworkInterface;
if(wzc != null)
{
....
}
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


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
 
G

Guest

Did you add this to the bugzilla database at http://bugzilla.opennetcf.com?
We're currently walking through the open bugs for 2.2 SP1 and we can have
the guys look at that while they're doing so.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


Andy Baker said:
Hi Chris

Any more news on this since I sent my code to (e-mail address removed)?
Thanks.

Andy Baker

Andy Baker said:
OK, I'll do that - thanks.

Andy Baker

I'm on the road all this week so I have no way to test the code or put
together a sample (I didn't bring any WinMo devices with me). Your best
bet at this point is to send an email to (e-mail address removed) with this
same info and we'll see what we can figure out, but I tested this stuff
fairly heavily back when I rewrote it (though with a very limited set of
hardware).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


Thanks Chris, that recognises the card as a wzc network interface.
Could you just clarify what some of the other methods are supposed to
do. The way that I am hoping for it to work is that when I start the
application, I set up the preferred list of networks and then connect
to the appropriate one as and when I want to. As one of the 'networks'
is a printer, it is possible that if the printer is changed, the SSID
of the printer will change, so I could end up with several printers in
the preferred list. For this reason I want to remove any old ones from
the preferred list. I am using PreferredAccessPoints to get the current
list, then RemovePreferredNetwork to remove ones that I don't need any
more - but RemovePreferredNetwork always returns false, and doesn't
remove any networks.
I am then using AddPreferredNetwork to add networks that are not in
the preferred list but I do need. This adds the required network (and
returns true), but it also seems to remove anything already in the
preferred list - if I have my WAP set up in the preferred list, then
add the printer from code, when I look at the preferred list
afterwards, it just contains the printer. Is this how it is supposed to
work, or am I doing something wrong?
Then, I want to use ConnectToPreferredNetwork to connect to the
network that I want to use. If I only have one network in the preferred
list, it obviously connects to it automatically (if it is there), but
if I have both in the preferred list I am trying to use
ConnectToPreferredNetwork to switch to the other one, but it doesn't do
it, and returns false.
Finally, as a test for whether I am conncted or not, I am checking
the IP address, and if it returns 0.0.0.0, I assume that I am not
connected. However, CurrentIPAddress sometimes returns 0.0.0.0 even
when I am connected, and can ping the network that I am connected to.
Why should it do this, and is there a better test for connectivity?
Thanks for all your help.

Andy Baker

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
Just go with something simple:

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
if (o is WirelessZeroConfigNetworkInterface)
{
....
}
}

or

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
WirelessZeroConfigNetworkInterface wzc = o as
WirelessZeroConfigNetworkInterface;
if(wzc != null)
{
....
}
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


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
 
A

Andy Baker

I sent an email as you requested and Juan Arroyo asked me for a code sample
and said thay would look at it and get back to me. I will add it to the
bugzilla database as well if you like.

Andy Baker

Did you add this to the bugzilla database at
http://bugzilla.opennetcf.com? We're currently walking through the open
bugs for 2.2 SP1 and we can have the guys look at that while they're doing
so.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


Andy Baker said:
Hi Chris

Any more news on this since I sent my code to (e-mail address removed)?
Thanks.

Andy Baker

Andy Baker said:
OK, I'll do that - thanks.

Andy Baker

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
I'm on the road all this week so I have no way to test the code or put
together a sample (I didn't bring any WinMo devices with me). Your
best bet at this point is to send an email to (e-mail address removed)
with this same info and we'll see what we can figure out, but I tested
this stuff fairly heavily back when I rewrote it (though with a very
limited set of hardware).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


Thanks Chris, that recognises the card as a wzc network interface.
Could you just clarify what some of the other methods are supposed to
do. The way that I am hoping for it to work is that when I start the
application, I set up the preferred list of networks and then connect
to the appropriate one as and when I want to. As one of the 'networks'
is a printer, it is possible that if the printer is changed, the SSID
of the printer will change, so I could end up with several printers in
the preferred list. For this reason I want to remove any old ones from
the preferred list. I am using PreferredAccessPoints to get the
current list, then RemovePreferredNetwork to remove ones that I don't
need any more - but RemovePreferredNetwork always returns false, and
doesn't remove any networks.
I am then using AddPreferredNetwork to add networks that are not in
the preferred list but I do need. This adds the required network (and
returns true), but it also seems to remove anything already in the
preferred list - if I have my WAP set up in the preferred list, then
add the printer from code, when I look at the preferred list
afterwards, it just contains the printer. Is this how it is supposed
to work, or am I doing something wrong?
Then, I want to use ConnectToPreferredNetwork to connect to the
network that I want to use. If I only have one network in the
preferred list, it obviously connects to it automatically (if it is
there), but if I have both in the preferred list I am trying to use
ConnectToPreferredNetwork to switch to the other one, but it doesn't
do it, and returns false.
Finally, as a test for whether I am conncted or not, I am checking
the IP address, and if it returns 0.0.0.0, I assume that I am not
connected. However, CurrentIPAddress sometimes returns 0.0.0.0 even
when I am connected, and can ping the network that I am connected to.
Why should it do this, and is there a better test for connectivity?
Thanks for all your help.

Andy Baker

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
Just go with something simple:

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
if (o is WirelessZeroConfigNetworkInterface)
{
....
}
}

or

foreach(object o in NetworkInterface.GetAllNetworkInterfaces())
{
WirelessZeroConfigNetworkInterface wzc = o as
WirelessZeroConfigNetworkInterface;
if(wzc != null)
{
....
}
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top