Main Site Documentation

G120 (Cobra II) strange error with streamreader


#1

I have the following error when I try to use the line below.


    #### Exception System.IndexOutOfRangeException - 0xa9000000 (1) ####
    #### Message: 
    #### System.IO.StreamReader::Peek [IP: 001c] ####
    #### System.IO.StreamReader::ReadLine [IP: 005e] ####
    #### CobraTest.Program::LoadSetup [IP: 0047] ####
    #### CobraTest.Program::ProgramStarted [IP: 00c6] ####
    #### CobraTest.Program::Main [IP: 0015] ####
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.IO.dll

This is the code line that it fails at:


line = reader.ReadLine();

line is a String variable.

I have a text file similar to an INI file and it fails on the line after “MAXMOISTUR4.5” (This is not the complete file, only part of it)


MAXDEPTH=0.402832001
MINMOISTURE=2.5
MAXMOISTURE=4.5
MINMLEVEL=10
MINWLEVEL=10
WATERACTIVE=True

The file reads OK on a PC and a hex editor shows the CR & LF at the end of each line as expected.


#2

Can you narrow your code down small enough to post? – I.e. just a small program that opens, loops to read and exits? Does the error occur in the same place if you re-arrange lines.? Is it specific to the number of bytes that have been read so-far? Versions of SDK you are using?


#3

see also this thread http://www.ghielectronics.com/community/forum/topic?id=8577&page=1#msg84980


#4

Hi Jeff,

Thanks for the link. Using the code posted there, the system runs fine so it appears to be a bug in the SDK.


#5

The best way is to add to codeplex then we can vote and put special requests.


#6

@ Gus, @ andre.m - the bug referred to in the other threads was closed http://netmf.codeplex.com/workitem/480 so I’m not sure what is going on here is the same ?

@ Dave Glad you got it working! What version of NETMF are you targeting?


#7

@ Jeff. 4.2 on a Cobra II board.

The exact same code works fine on 4.1 with a ChipworkX module on a custom board.


#8

Duplicated problem so added to codeplex: http://netmf.codeplex.com/workitem/2048