Main Site Documentation

Ethernet_ENC28 ERROR : DHCP Error - networking may not work


#1

Hi

I’m using a Raptor with the enc28 module and I receive the following message

Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (4)

#### Message: 
#### Gadgeteer.Modules.Module+NetworkModule::DHCPThread [IP: 001f] ####

A first chance exception of type ‘System.NullReferenceException’ occurred in Gadgeteer.dll
Ethernet_ENC28 ERROR : DHCP Error - networking may not work

here my code in the ProgramStarted

Core.Initialize(TouchCollection.NativeSingleTouch);
ethernet_ENC28.Interface.Open();
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_ENC28.Interface);

        ethernet_ENC28.Interface.CableConnectivityChanged += new EthernetENC28J60.CableConnectivityChangedEventHandler(Interface_CableConnectivityChanged);
        ethernet_ENC28.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);

        ethernet_ENC28.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_ENC28_NetworkUp);
        ethernet_ENC28.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_ENC28_NetworkDown);

        ethernet_ENC28.UseDHCP();

        Debug.Print("Program started!");

#2

You’ll want to use ethernet_ENC28.Interface.NetworkInterface.EnableDhcp(); instead of ethernet_ENC28.UseDHCP();

Additionally, you’ll want to assign the event handlers before anything else to make sure you don’t miss any events.