Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino plus 1 System Exception

Netduino plus system exception ethernet problem networkinterface

  • Please log in to reply
1 reply to this topic

#1 victorSantana09

victorSantana09

    Member

  • Members
  • PipPip
  • 10 posts

Posted 09 July 2014 - 01:41 PM

Hello guys!

 

 

I'm trying to execute a sample of netduino webserver ,but i'm getting the following 

error :  Ocurred one untreated exception of the type 'System.Exception' in Microsoft.SPOT.Net.dll

When i execute the following method : NetworkInterface.GetAllNetworkInterfaces()[0];

 

I already tried with another code posted here in the forums.

 

I attached a print of the error and the code . Any ideas of whats happening ? 

 

 

Thanks in advance! ;)

Attached Files



#2 FredOrJoeBlogs

FredOrJoeBlogs

    New Member

  • Members
  • Pip
  • 4 posts

Posted 12 August 2014 - 10:06 PM

Hi,

I'm not sure of you level of C# experience so I will try and explain this in basic terms, I hope I'm not patronising you.

 

Your syntax isn't quite right.  On the line where you have:

            //display the IP adress
            NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
 

The square brackets are in the wrong place, it should be:

            //display the IP adress
            NetworkInterface [] networkInterface = NetworkInterface.GetAllNetworkInterfaces();

This will declare an array of NetworkInterface objects, which will be filled with the result of the function call.
This will make you while loop condition wrong, and everywhere else you use the networkInterface variable, because now networkInterface is now an array rather than a single item.

So this should give you a good start

            while (networkInterface[0].IPAddress.ToString().Equals("0.0.0.0"))
            {
                networkInterface = NetworkInterface.GetAllNetworkInterfaces();
                Debug.Print("Meu IP:" + networkInterface[0].IPAddress.ToString());
                Thread.Sleep(2000);
            }
            Debug.Print("Meu IP:" + networkInterface[0].IPAddress.ToString());

I have't tested any of this, because I was a cheep skate and didn't get the Ethernet socket, but if there is any problems I'll look at them as soon as I can.
 







Also tagged with one or more of these keywords: Netduino, plus, system, exception, ethernet, problem, networkinterface

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.