A strange problem occured with an application that was working. (A work in progress). I am using GHI .NET Micro Framework 4.2
I am assuming it is a issue with my Visual Studio C# Express but I’m not sure.
Here is a partial Debug Output:
The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZSpider version 1.0
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
#### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
#### Message:
#### GHI.Premium.Net.NetworkInterfaceExtension::Activate [IP: 001a] ####
#### WiFi42.Program::startWIFI [IP: 0048] ####
#### WiFi42.Program::ProgramStarted [IP: 0005] ####
A first chance exception of type ‘GHI.Premium.Net.NetworkInterfaceExtensionException’ occurred in GHI.Premium.Net.dll
!Exception AssignNetworkingStackTo: Exception was thrown: GHI.Premium.Net.NetworkInterfaceExtensionException
*Connected to network…
*NetworkDown event!
The thread ‘’ (0x3) has exited with code 0 (0x0).
*WirelessConnectivityChanged event!
*RSSI : 62
*IP Address : 0.0.0.0
*e.IsConnected
*NetworkAddressChanged event!
*IP Address : 192.168.2.6
I have stripped down the application by removing everything except the WIFI and some Debug.Print (messages)
I have added some comments << “comments about the code”
using System;
using Microsoft.SPOT;
using GHI.Premium.Net;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
// Using GHI .NET Micro Framework 4.2
namespace WiFi42
{
public partial class Program
{
static bool useDebug = true; //Your choice...true/false
void ProgramStarted()
{
startWIFI();
}
void startWIFI()
{
<< I will receive a exception here if I mouse over this statement and click the little X block to show additional detail
if (!wifi_RS21.Interface.IsOpen)
{
wifi_RS21.Interface.Open();
}
if (!wifi_RS21.Interface.NetworkInterface.IsDhcpEnabled)
{
wifi_RS21.Interface.NetworkInterface.EnableDhcp();
}
try
{
<< I added a Try/Catch here to show the exception. This is where the exception occurs.
NetworkInterfaceExtension.AssignNetworkingStackTo(wifi_RS21.Interface); }
catch (Exception e)
{
if (useDebug) { Debug.Print("!Exception AssignNetworkingStackTo: " + e.Message); }
}
wifi_RS21.Interface.WirelessConnectivityChanged +=
new WiFiRS9110.WirelessConnectivityChangedEventHandler(Interface_WirelessConnectivityChanged);
wifi_RS21.Interface.NetworkAddressChanged +=
new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);
wifi_RS21.NetworkDown +=
new GTM.Module.NetworkModule.NetworkEventHandler(wifi_RS21_NetworkDown);
wifi_RS21.NetworkUp +=
new GTM.Module.NetworkModule.NetworkEventHandler(wifi_RS21_NetworkUp);
try
{
WiFiNetworkInfo[] ScanResp = wifi_RS21.Interface.Scan("xxxxxxxxxx"); // Router SSID needed here
if (ScanResp != null && ScanResp.Length > 0)
{
wifi_RS21.Interface.Join(ScanResp[0], "xxxxxxxx"); //Your passkey needed here
if (useDebug) { Debug.Print("*Connected to network..."); }
}
else
{
if (useDebug) { Debug.Print("*Wireless network was not found"); }
}
}
catch (Exception e)
{
if (useDebug) { Debug.Print("!Exception : " + e.Message); }
}
}
//
void wifi_RS21_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
if (useDebug) { Debug.Print("*NetworkUp event!"); }
}
//
void wifi_RS21_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
if (useDebug) { Debug.Print("*NetworkDown event!"); }
}
//
void Interface_WirelessConnectivityChanged(object sender, WiFiRS9110.WirelessConnectivityEventArgs e)
{
if (useDebug)
{
Debug.Print("*WirelessConnectivityChanged event!");
Debug.Print("*RSSI : " + e.NetworkInformation.RSSI.ToString());
Debug.Print("*IP Address : " + wifi_RS21.Interface.NetworkInterface.IPAddress);
}
if (e.IsConnected)
{
if (useDebug) { Debug.Print("*e.IsConnected"); }
}
}
//
void Interface_NetworkAddressChanged(object sender, EventArgs e)
{
if (useDebug)
{
Debug.Print("*NetworkAddressChanged event!");
Debug.Print("*IP Address : " + wifi_RS21.Interface.NetworkInterface.IPAddress);
}
}
//
} //end class
} //end namespace
I found it curious that during debug if I set a breakpoint past the code and then did a mouse over the statement and click the little X block to show additional detail
that it displayed an exception? Maybe this is normal but I have never seen it before in any code. Image 1 of 3 shows where I get the mouse over and click exception
I am including a few screen captures to illustrate.
I have uninstalled all of the GHI software (Including the USB drivers) and reinstalled everything. I have erased the Spider firmware and reinstalled it. Same thing happens.
The complete app was running OK but then something happened. I have no idea what! I do not recall changing anything in the Visual Studio. I also did a repair on the Microsoft
SDK’s.
Anybody have any ideas on what caused this or possible solutions?