Thank you very much for your answer, “Wouter Huysentruit” and “ransomhall” !
I have tried your suggestion, but it doesn’t work.http://www.tinyclr.com/forum/21/5998/
I find a very interesting situation, if I write codes as follow:
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Ethernet_test
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
ethernet.UseDHCP();
//ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
Debug.Print("Connected to network.");
Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
WebServer.StartLocalServer("192.168.1.200", 80);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
}
/* void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("Connected to network.");
Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
WebServer.StartLocalServer("192.168.1.200", 80);
}*/
}
}
In the windows output I can get the right result.
It doesn’t matter with connectting or un connectting the network cable while my program is running.
But if I write codes like as follow:
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Ethernet_test
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
ethernet.UseDHCP();
ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
}
void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("Connected to network.");
Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
WebServer.StartLocalServer("192.168.1.200", 80);
}
}
}
the windows output show me:
…
…
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll” geladen
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZSpider.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Dokumente und Einstellungen\Zalud\eigene dateien\visual studio 2010\Projects\Ethernet_test\Ethernet_test\bin\Debug\le\Ethernet_test.exe” geladen, Symbole geladen.
Der Thread ‘’ (0x2) hat mit Code 0 (0x0) geendet.
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
I have tried to unconnect and then later reconnect the network cable while myprogram is running.
But it doesn’t work.
I have even tried a simple example as follow:
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Ethernet_test
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
ethernet.UseDHCP();
ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
}
void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("ethernet_NetworkUp Started");
}
}
}
the window output show me the same problem as follow
…
…
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Ethernet_J11D\NETMF 4.1\le\GTM.GHIElectronics.Ethernet_J11D.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll” geladen
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZSpider.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Dokumente und Einstellungen\Zalud\eigene dateien\visual studio 2010\Projects\Ethernet_test\Ethernet_test\bin\Debug\le\Ethernet_test.exe” geladen, Symbole geladen.
Der Thread ‘’ (0x2) hat mit Code 0 (0x0) geendet.
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
the “void ethernet_NetworkUp()” doesn’t work.
I am confused about it, can you give me some suggestions?
I look forward to your answer.