Main Site Documentation

Simple HTTP server - Codeshare Error


#1

Hi,

Have just started to begin looking at moving to 4.2 and was testing out the changes to the way Ethernet is initialised, so was using the example found on Codeshare:

http://www.tinyclr.com/codeshare/entry/588

I was getting very frustrated as to why it was not working and stuck in the loop of “IP address is not set yet.” I thought at first it was my hardware but after awhile went back to the sample code and noticed the order in which the code is executed:

        Eth1.NetworkInterface.EnableStaticIP(myIP, "255.255.255.0", "192.168.0.2");
        IPAddressSetResetEvent = new ManualResetEvent(false);
        Eth1.CableConnectivityChanged += new EthernetBuiltIn.CableConnectivityChangedEventHandler(Eth1_CableConnectivityChanged);
        Eth1.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Eth1_NetworkAddressChanged);

In this order the static IP is set before the event handlers are initialised, so the Network Address event will never fire and thus you will be stuck in the loop of “IP address is not set yet.”

This Codeshare sample needs changed to:

        IPAddressSetResetEvent = new ManualResetEvent(false);
        Eth1.CableConnectivityChanged += new EthernetBuiltIn.CableConnectivityChangedEventHandler(Eth1_CableConnectivityChanged);
        Eth1.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Eth1_NetworkAddressChanged);
        Eth1.NetworkInterface.EnableStaticIP(myIP, "255.255.255.0", "192.168.0.2");

#2

There is a new version of the code that should eliminate the issue that you are having.