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

Using SD cards on N+2?

sd 4.2.2.0

Best Answer TKS, 24 January 2013 - 12:37 AM

If not already done, add System.IO to your projects references.

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 Verdris

Verdris

    Advanced Member

  • Members
  • PipPipPip
  • 128 posts
  • LocationReno, NV

Posted 24 January 2013 - 12:26 AM

I can't seem to get anything SD-related working on my up-to-date N+2.

 

Here's my test code:

using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using System.IO;namespace NetduinoApplication1{    public class Program    {        public static void Main()        {            // Test writing to file            using (var filestream = new FileStream(@"SDtest.txt", FileMode.Create))            {                StreamWriter streamWriter = new StreamWriter(filestream);                streamWriter.WriteLine("nThis is a test...nThis is only a test...n");                streamWriter.Close();            }            // Test reading from file just written            using (var filestream = new FileStream(@"SDtest.txt", FileMode.Open))            {                StreamReader reader = new StreamReader(filestream);                Debug.Print(reader.ReadToEnd());                reader.Close();            }        }    }}

 

And here are the errors:

Error 1 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The name 'FileMode' does not exist in the current context
Error 3 The type or namespace name 'StreamWriter' could not be found (are you missing a using directive or an assembly reference?)
Error 4 The type or namespace name 'StreamWriter' could not be found (are you missing a using directive or an assembly reference?)
Error 5 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?)
Error 6 The name 'FileMode' does not exist in the current context
Error 7 The type or namespace name 'StreamReader' could not be found (are you missing a using directive or an assembly reference?)
Error 8 The type or namespace name 'StreamReader' could not be found (are you missing a using directive or an assembly reference?)
 
 
Ideas? According to http://msdn.microsof...y/dd169832.aspx, these are all part of the System.IO namespace, but they're not working. I can't even say 
FileStream derp = new System.IO.FileStream(blah blah blah));

 

In fact, the only members of System.IO I have access to are IOException, Ports, SeekOrigin, and Stream. I'm using .NETMF 4.2 and a board with the new shiny firmware.

 

/stumped.



#2 TKS

TKS

    New Member

  • Members
  • Pip
  • 4 posts

Posted 24 January 2013 - 12:37 AM   Best Answer

If not already done, add System.IO to your projects references.



#3 Verdris

Verdris

    Advanced Member

  • Members
  • PipPipPip
  • 128 posts
  • LocationReno, NV

Posted 24 January 2013 - 12:46 AM

If not already done, add System.IO to your projects references.

Thanks. This lets me compile the code and exposes all the members of the System.IO class. Code uploads and works as expected.

 

I guess the lesson here is that a "using" statement doesn't automatically add the namespace to the program references?

 

The problem I'm having now is that whenever I insert or remove a sd card from my NP2, I have to power cycle it to get new code to upload.



#4 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 24 January 2013 - 11:09 AM

Thanks. This lets me compile the code and exposes all the members of the System.IO class. Code uploads and works as expected.

 

I guess the lesson here is that a "using" statement doesn't automatically add the namespace to the program references?

 

The problem I'm having now is that whenever I insert or remove a sd card from my NP2, I have to power cycle it to get new code to upload.

 

You are correct and this goes for any visual studio project.  You need to add the reference in order to add the using so the DLL will deploy with your solution.

 

I've never noticed this behavior with the ND+2 SD card removal.  I'll try to test the same here later today.







Also tagged with one or more of these keywords: sd, 4.2.2.0

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.