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

Cant add refrences


  • Please log in to reply
18 replies to this topic

#1 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 05:09 AM

In my program I am trying to add the following references. I use these for a c# program I use to get stock data. using System.Collections.Generic using System.Linq using System.Web using System.Web.UI using System.Xml.Linq Please help.
Steve


My Other Hobby: Engineer Turned Baker

#2 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 05:13 AM

I need 2 more as well ... using System.Net; using System.Net.Mail;
Steve


My Other Hobby: Engineer Turned Baker

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2012 - 06:01 AM

Hi smarcus3, Most/all of these are features which exist in the .NET Framework on the desktop, but not in the .NET Micro Framework. .NET Micro Framework is a subset of the full .NET Framework -- plus features designed expressly for microcontrollers (like analog inputs, input/output on MCU pins, PWM, etc.) Chris

#4 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:20 AM

Is there a way to get filestream?
Steve


My Other Hobby: Engineer Turned Baker

#5 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:20 AM

I want to read in a page like this one ... http://www.google.co.../api?stock=GOOG
Steve


My Other Hobby: Engineer Turned Baker

#6 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:23 AM

1 last thing the xml files should always be approx 1kb
Steve


My Other Hobby: Engineer Turned Baker

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2012 - 06:27 AM

Is there a way to get filestream?

Sure thing. Pull in System.IO.dll.

Chris

#8 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:30 AM

I already have using system.io and it doesn't work. Do you mean something else?
Steve


My Other Hobby: Engineer Turned Baker

#9 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:31 AM

Nevermind. Had a brain fart. I guess it happens at 230AM
Steve


My Other Hobby: Engineer Turned Baker

#10 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:44 AM

My link is apparently a URI. Any ideas how to read it?
Steve


My Other Hobby: Engineer Turned Baker

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2012 - 06:45 AM

My link is apparently a URI. Any ideas how to read it?

You can use System.Net.Sockets (or the HttpWebRequest class).

Take a look at the "SocketClint" sample in the .NET MF SDK.

Chris

#12 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:48 AM

where are those examples? Thanks for all the help.
Steve


My Other Hobby: Engineer Turned Baker

#13 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 06:50 AM

nvm
Steve


My Other Hobby: Engineer Turned Baker

#14 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 07:13 AM

That example seems to work for a webpage but not the uri page that just returns an xml
Steve


My Other Hobby: Engineer Turned Baker

#15 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 07:27 AM

This code only get the first 2 lines of the xml file. Why is that??? StreamReader reader = new StreamReader(WebRequest.Create(url).GetResponse().GetResponseStream());
Steve


My Other Hobby: Engineer Turned Baker

#16 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 08 April 2012 - 07:19 PM

I believe I got it working using the HTTPWebRequest. I don't have my netduino here yet so I write my code using the .netMF side and paste it into a .net program to simulate the results.

Here is the code:

string url = "http://www.google.com/ig/api?stock=" + symbol;


            // used to build entire input
            StringBuilder sb = new StringBuilder();

            // used on each read operation
            byte[] buf = new byte[8192];

            // prepare the web page we will be asking for
            HttpWebRequest request = (HttpWebRequest)
                WebRequest.Create(url);

            // execute the request
            HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();

            // we will read data via the response stream
            Stream resStream = response.GetResponseStream();

            string tempString = null;
            int count = 0;

            do
            {
                // fill the buffer with data
                count = resStream.Read(buf, 0, buf.Length);

                // make sure we read some data
                if (count != 0)
                {
                    // translate from bytes to ASCII text
                    tempString = Encoding.ASCII.GetString(buf, 0, count);

                    // continue building the string
                    sb.Append(tempString);
                }
            }
            while (count > 0); // any more data to read?

            string temp = sb.ToString();

And here is the stringbuilder class.

using System;
using Microsoft.SPOT;
using System.Collections;

namespace System.Text
{
 
        class StringBuilder
        {
            ArrayList m_charArray = new ArrayList();

            public StringBuilder()
            {
            }

            public StringBuilder(string value)
                : base()
            {
                Append(value);
            }

            public void Append(string value)
            {
                Char[] charArray = value.ToCharArray();
                Append(charArray, 0, charArray.Length);
            }

            public void Append(char[] value, int startIndex, int charCount)
            {
                for (int index = startIndex; index < startIndex + charCount; index++)
                    m_charArray.Add(value[index]);
            }

            public int Length
            {
                get
                {
                    return m_charArray.Count;
                }
            }

            public override string ToString()
            {
                return new string((char[])m_charArray.ToArray(typeof(char)));
            }
            }
        }
    

Steve


My Other Hobby: Engineer Turned Baker

#17 Wasatch Wired

Wasatch Wired

    New Member

  • Members
  • Pip
  • 1 posts

Posted 02 June 2012 - 06:44 PM

Sure thing. Pull in System.IO.dll.

Chris

Can you explain "Pull in System.IO.dll"?
I am trying to write to an SD card on a Netduino Plus and I either get the error that I'm missing a namespace or dll, or when I go 'Project' -> 'Add Reference', I'm not sure what I'm supposed to do as there are a few tabs, but nothing that allows any adding of anything. I'm familiar with Eclipse, and Visual Studio is very new to me.

#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 June 2012 - 09:20 PM

HI Wasatch,

Can you explain "Pull in System.IO.dll"?
I am trying to write to an SD card on a Netduino Plus and I either get the error that I'm missing a namespace or dll, or when I go 'Project' -> 'Add Reference', I'm not sure what I'm supposed to do as there are a few tabs, but nothing that allows any adding of anything. I'm familiar with Eclipse, and Visual Studio is very new to me.

Oh, no problem. Right click on your References folder in the Solution Explorer pane and then select "Add References...". Click on the first tab (.NET). Scroll down to "System.IO", select it, and press OK.

Chris

#19 Teets

Teets

    Member

  • Members
  • PipPip
  • 16 posts

Posted 26 June 2012 - 10:54 PM

I don't have my netduino here yet so I write my code using the .netMF side and paste it into a .net program to simulate the results.


You can run your MF code against the emulator... would be a more reliable approach, too.




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.