Reading XML file off SD card not working properly

I am trying to read a file from the SD card and I got some real issues with it.
Code has been taken from an example on this site.
It only works about 20% of the time.
I have uploaded the firmware multiple times, as I thought it would reset the board and also deleted the app, but still no good.

Code used - put together, as split up into procedures of a class, shown below.

[quote]PersistentStorage m_oCard = new PersistentStorage( “SD” );

m_oCard.MountFileSystem( );

RemovableMedia.Insert += RemovableMedia_Insert;
RemovableMedia.Eject += RemovableMedia_Eject;

public void RemovableMedia_Insert( object sender, MediaEventArgs e )
{
VolumeInfo oVolume = VolumeInfo.GetVolumes()[0];

XmlReaderSettings oReader = new XmlReaderSettings( );

oReader.IgnoreWhitespace = true;
oReader.IgnoreComments = true;

FileStream oConfigFile = new FileStream( oVolume.RootDirectory + @ “\test.conf”, FileMode.OpenOrCreate, FileAccess.Read );

XmlReader xmlr = XmlReader.Create( oConfigFile, oReader );

while ( !xmlr.EOF )
{
xmlr.Read( );

}

}[/quote]

I get exceptions at the following lines:

  1. new PersistentStorage( “SD” );
  2. FileStream oConfigFile = new FileStream( oVolume.RootDirectory + @ “\test.conf”, FileMode.OpenOrCreate, FileAccess.Read );
  3. XmlReader xmlr = XmlReader.Create( oConfigFile, oReader );
  4. xmlr.Read( );

When looking at the exception object, it just says “Exception”, no code or message.
Have to reboot computer again, so will add another post with output messages.

Would be great if anyone has got an idea.

development env:
windows server 2003R2 in virtual machine (Parallels) on macBook pro.
VS 2010 ultimate

Your question is missing one or more of these details:[ul]
The name of the product.
The code you’re trying to run.
Details on your setup.[/ul]
(Generated by QuickReply - edited by hand)
Can you tell us what Fez you’re using this on? It seems unrelated to memory, but as soon as you talk XML that’s always a concern.

Further, I would find a sample code that just reads a text file and outputs it with debug.prints, so you can see that your card access is ok

Sorry,

The app is very small, so is the RLP module.
Also tried using a 9V power supply, as I got serious issues with getting connection to Panda II.
I always got to reboot my computer to get a another connection.
This is ssssooooooo frustrating

I would find a sample code that just reads a text file
Ok, will give that a try.

I’d take it step by step, prove you can reliably get an SD card mounted and reading just in it’s own app before you go integrating it into anything else. You will find a number of other people who have had issues with different brands of SD card, often related to power fluctuations at the SD card interface - search for some of the other threads if you like.