I'm using a Fez Spider mainboard and Ethernet J11D module and it seems that the Ethernet module works a bit differently under NetMF 4.2 that what i'm used to.
Adding the Ethernet module to the Gadgeteer visual designer in the same way as other modules will cause a null reference exception.
We no longer need to add the Ethernet module to the designer. Instead we use the EthernetBuiltIn class and the NetworkInterfaceExtension.AssignNetworkingStackTo method.
You can find some sample code to get the Ethernet module working below.
You'll need to add a reference to GHI.Premium.Net for the EthernetBuiltIn class.
You'll need to add a reference to GHI.Premium.Net for the EthernetBuiltIn class.
static readonly EthernetBuiltIn Ethernet = new EthernetBuiltIn();
void ProgramStarted()
{
Debug.Print("Program Started");
Ethernet.Open();
NetworkInterfaceExtension.AssignNetworkingStackTo(Ethernet);
Ethernet.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Ethernet_NetworkAddressChanged);
Ethernet.NetworkInterface.EnableDhcp();
}
void Ethernet_NetworkAddressChanged(object sender, EventArgs e)
{
Debug.Print("Network Address Changed");
Debug.Print(Ethernet.NetworkInterface.IPAddress);
}
This code should be enough to get you started with the Ethernet module under NETMF 4.2