SD card no longer working after 4.2 RC3 upgrade


Hoping for some ideas on why my SD card no longer reads or writes after my upgrade to Firmware_NetduinoPlus_4.2.0.0_RC3.

I am using a 4gig HD SD card that worked with the same source code on a later version of 4.1, in fact its been logging data and running a threaded web server for about a month without this problem.

Today, after the upgrade, my code no longer works, so to try to debug it I have been using someones test code that reproduces the same fault. See below.(Thanks for the demo code)

Firstly an exception gets thrown as the first line runs. This has been mentioned in the forums and after about 30 seconds the code continues.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Secret Labs\Netduino SDK\Assemblies\v4.2\le\SecretLabs.NETMF.Hardware.NetduinoPlus.dll', Symbols loaded.
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.SPOT.Native.dll

(I am not sure if this is part of the main problem, I just included it for completeness, apparently it will be suppressed in the release build. All I can say is that waiting 30 seconds or so is annoying.)

The real problem happens when an exception gets thrown on Directory.SetCurrentDirectory(root);

A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.IO.dll
A first chance exception of type 'System.IO.IOException' occurred in System.IO.dll

If I dig deeper into the exception I get
ErrorCode DirectoryNotFound System.IO.IOException.IOExceptionErrorCode

There is also m_HResult -486539264 int

There clearly is a directory here because the previous line
System.IO.Directory.GetDirectories(@"\") returns an array of which element the first element is "\SD";

Other things to bear in mind are I installed the RC3 in the correct order as per the instructions and all the referenced .net micro framework assemblies have a version of 4.2 and a runtime version of v4.0.30319 (Although I dont know what the difference is)

Here is the full test code.

using System;
using System.IO;
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.NetduinoPlus;

namespace MicroSdTest
public class Program
    private static System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

    const String root = "\\SD";

    public static void Main()

            String[] files = Directory.GetFiles(".");
            foreach (String file in files)

            String dir = Directory.GetCurrentDirectory();
            String fileName = "testsdcard4gig.txt";

            String testWrite = "Hejsan hoppsan i lingonskogen!";
            File.WriteAllBytes(fileName, encoding.GetBytes(testWrite));

            byte[] testRead = File.ReadAllBytes(fileName);
            Debug.Print(new String(encoding.GetChars(testRead)));

        catch (Exception ex)


The initial thread where this was logged is


Garrcomm wrote Feb 6, 2012 at 5:45 PM

I just tested exactly your code with a couple of µSD-cards on firmware 4.2RC4, and got the following results:

Tested µSD-cards:
  • Sandisk 1GB - success
  • Sandisk 2GB - success
  • Sandisk 8GB - fail
  • A Data 8GB - fail
  • A Data 16GB - fail
So it looks like SDHC support is not working anymore.

Garrcomm wrote Feb 6, 2012 at 9:23 PM

I have discussed this, but it seems the 4.2RC4 doesn't have SDHC support, nor did previous 4.2 builds had. It's currently only available in Firmware v4.1.1 BETA 1 (which is also no final release)

codekaizen wrote Jun 13, 2012 at 10:32 PM