Main Site Documentation

NetworkChange.NetworkAddressChanged and NetworkChange.NetworkAvailabilityChanged not firing


#1

• We are using .NETMF 4.1
• GHIElectronics.NETMF 4.17
• DPWS_V_4_1_7706_0
• WsHttp configured web services

  1. When our application starts up we call this method:

        private static void EnabledDhcp()
        {
     try
            {
                if (!Ethernet.IsEnabled)
                    Ethernet.Enable();

                if (!Ethernet.IsCableConnected)
                    Site.Net.IsNetworkAvailable = false;
                else
                {
var network = Site.Net.GetNetworkInterface();

                    if (!network.IsDhcpEnabled)
                        network.EnableDhcp();

                    network.RenewDhcpLease();
                }
     }
            catch (Exception)
            {
                Site.Net.IsNetworkAvailable = false;
            }
        }


It was my understanding that this would bind the network stack thus allowing us to subscribe to the following events for detecting network changes/outages. Moreover, it would enable DHCP and create a DHCP lease with the DHCP Server:
NetworkChange.NetworkAddressChanged += networkAddressChanged;
NetworkChange.NetworkAvailabilityChanged += networkAvailabilityChanged;

From what I have seen, these events never fire. Most importantly, we were relying on the NetworkChange.NetworkAvailabilityChanged event to signal changes in network availability. As a result, we are reduced to polling to pre-emptively detect network outages


#2

I do not have an answer myself but please use code tags so your code is readable. Another support engineer will help you out.


#3
NetworkChange.NetworkAddressChanged += networkAddressChanged;

This event is not supported.

NetworkChange.NetworkAvailabilityChanged += networkAvailabilityChanged

This fires if the Ethernet cable is connected or disconnected.

Please take a look at the example code under GHIElectronics.NETMF.Networking.Ethernet for more details on how to use Dhcp with Ethernet.