Main Site Documentation

Mountaineer Ethernet mainboard Gadgeteer.WebServer error


#1

Hi,
I upgraded Mountaineer Ethernet mainboard to latest firmware and SDK (Release 4.3.1 beta 3) and would like to test simple example of Web Service that allows to remotely control the on-board LED (from http://mikedodaro.net/2012/10/01/playing-with-mountaineer-ethernet-mainboard/).
When I call web event to handle requests on led path (http://10.230.17.212/led?mode=on) I get error in Visual Studio:
The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard The Mountaineer Group MountaineerEth version 1.0
Web server started at http://10.230.17.212:80/
Program Started
The thread ‘’ (0x3) has exited with code 0 (0x0).
A first chance exception of type ‘System.IndexOutOfRangeException’ occurred in Gadgeteer.WebServer.dll
The thread ‘’ (0x6) has exited with code 0 (0x0).
The program ‘[2] Micro Framework application: Managed’ has exited with code 0 (0x0).

Code:

using System;
using System.Collections;
using System.Threading;
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.Mountaineer;

namespace HelloMountaineer
{
    public partial class Program
    {
        private GT.Timer tmrBlink;
        private bool isLedOn;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            ethernetForMountaineerEth.NetworkUp +=
               new GTM.Module.NetworkModule.NetworkEventHandler(ethernetForMountaineerEth_NetworkUp);
            ethernetForMountaineerEth.UseStaticIP("10.230.17.212", "255.255.0.0", "10.230.0.1");


            tmrBlink = new GT.Timer(500);
            tmrBlink.Tick += new GT.Timer.TickEventHandler(tmrBlink_Tick);

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
        }

        void ethernetForMountaineerEth_NetworkUp(GTM.Module.NetworkModule sender, 
            GTM.Module.NetworkModule.NetworkState state)
        {
            var ledEvent = WebServer.SetupWebEvent("led");
            ledEvent.WebEventReceived +=
                new WebEvent.ReceivedWebEventHandler(ledEvent_WebEventReceived);
            WebServer.StartLocalServer(ethernetForMountaineerEth.NetworkSettings.IPAddress, 80);

        }

        void ledEvent_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            try
            {
                Debug.Print("Start...");
                string mode = responder.GetParameterValueFromURL("mode").ToLower();
                if (mode == "on")
                {
                    tmrBlink.Stop();
                    isLedOn = true;
                }
                else if (mode == "blink")
                {
                    tmrBlink.Start();
                }
                else
                {
                    tmrBlink.Stop();
                    isLedOn = false;
                }

                Mainboard.SetDebugLED(isLedOn);
                responder.Respond("Success");
            }
            catch(Exception ex)
                {
                    Debug.Print(ex.ToString());
                }
        }

        void tmrBlink_Tick(GT.Timer timer)
        {
            isLedOn = !isLedOn;
            Mainboard.SetDebugLED(isLedOn);
        }
    }
}

#2

I tried but “Format as code” button doesn’t work :frowning:


#3

Thanks!!! :smiley:


#4

It’s most likely a bug in the Gadgeteer Webserver. I opened a ticket on the Gadgeteer Codeplex page: https://gadgeteer.codeplex.com/workitem/1861

Workaround: Download Gadgeteer Library from Codeplex, patch Responder.cs in the Webserver43 project (line 543) and add it to your project :wink: .

There’s also a race condition in the Gadgeteer library which prevents the DHCP Option to work correctly: https://gadgeteer.codeplex.com/workitem/1752

 
Thread.Sleep(1);
ethernetForMountaineerEth.UseDHCP();
ethernetForMountaineerEth.NetworkUp += ethernetForMountaineerEth_NetworkUp;
ethernetForMountaineerEth.NetworkDown += ethernetForMountaineerEth_NetworkDown;
Debug.Print("Program Started");


#5

Thanks. It works now. :clap: :clap:


#6

Hi, i have same problem, but when i try to patch responder.cs and than i put it in my project (project>add exist item) than visual studio show 20 errors.
Do you know what i did wrong?
Its my first experience with visual studio and Moutaineer ethernet mainboard.

Thank you
Klimoma

Error 1 No overload for ‘ledEvent_WebEventReceived’ matches delegate ‘Gadgeteer.Networking.WebEvent.ReceivedWebEventHandler’ C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Program.cs 40 17 HelloMountaineer
Error 3 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ContentType’ and no extension method ‘ContentType’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 57 26 HelloMountaineer
Error 4 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ResponseData’ and no extension method ‘ResponseData’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 58 26 HelloMountaineer
Error 5 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ContentType’ and no extension method ‘ContentType’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 87 26 HelloMountaineer
Error 6 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ResponseData’ and no extension method ‘ResponseData’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 89 26 HelloMountaineer
Error 7 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ContentType’ and no extension method ‘ContentType’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 104 26 HelloMountaineer
Error 8 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ResponseData’ and no extension method ‘ResponseData’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 105 26 HelloMountaineer
Error 9 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ContentType’ and no extension method ‘ContentType’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 121 26 HelloMountaineer
Error 10 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ResponseData’ and no extension method ‘ResponseData’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 122 26 HelloMountaineer
Error 11 ‘Gadgeteer.Networking.BinaryResponseTemplate’ is inaccessible due to its protection level C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 155 17 HelloMountaineer
Error 12 ‘Gadgeteer.Networking.WebEvent’ does not contain a definition for ‘ComputeResponse’ and no extension method ‘ComputeResponse’ accepting a first argument of type ‘Gadgeteer.Networking.WebEvent’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 155 65 HelloMountaineer
Error 13 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Header’ and no extension method ‘Header’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 157 30 HelloMountaineer
Error 14 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Header’ and no extension method ‘Header’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 157 57 HelloMountaineer
Error 15 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Header’ and no extension method ‘Header’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 159 53 HelloMountaineer
Error 16 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Header’ and no extension method ‘Header’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 159 73 HelloMountaineer
Error 17 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Content’ and no extension method ‘Content’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 161 34 HelloMountaineer
Error 18 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Content’ and no extension method ‘Content’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 161 62 HelloMountaineer
Error 19 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Content’ and no extension method ‘Content’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 163 57 HelloMountaineer
Error 20 ‘Gadgeteer.Networking.BinaryResponseTemplate’ does not contain a definition for ‘Content’ and no extension method ‘Content’ accepting a first argument of type ‘Gadgeteer.Networking.BinaryResponseTemplate’ could be found (are you missing a using directive or an assembly reference?) C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 163 78 HelloMountaineer
Error 21 ‘Gadgeteer.Networking.Body’ does not contain a constructor that takes 2 arguments C:\Users\klimoma\Documents\Visual Studio 2012\Projects\HelloMountaineer\HelloMountaineer\Responder.cs 246 33 HelloMountaineer


#7

Hi klimoma,
I followed workaround from user25519:Download Gadgeteer Library from Codeplex, patch Responder.cs in the Webserver43 project (line 543) and make dll. Copy Gadgeteer.WebServer.dll, Gadgeteer.WebServer.pdb, Gadgeteer.WebServer.xml into C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3 and include new dll into your project.


#8

hi,
Thx i did what you said and now its works, but not correctly :confused: when i send 6-7 requests (on/off/blink) so it stop response on http request.
Did u try more requests? Is it working for you?


#9

Hi,
for time being it works. No problem with response.