The code ran for 133 hours without failing. This would be the 267th
iteration of the (same) object and the code below is used 5 times
per iteration giving 1335 cycles. It was halfway through current
iteration at fail.
The raised exception (see below) does not seem to be documented
or under my control. It appears that methods internal to the
StreamReader class have failed.
Any idea if this is a bug or known problem?
string ReadResp(Stream stream,Encoding encoding,bool print, bool stop){
StreamReader reader=new StreamReader(st ream,encoding);
char[] read=new char[256];
int count;
StringBuilder str=new StringBuilder(" ");
count=reader.Re ad(read,0,256); //Exception thrown here
while(count > 0){
str.Append(read );
count=reader.Re ad(read,0,256); // Or here...
}
response=str.To String();
if( print )
Console.WriteLi ne(response);
if(stop){
Console.WriteLi ne("Press Enter to continue.");
Console.ReadLin e();
}
return response;
}
Main Exception raised!
Source :mscorlib
Message :Non-negative number required.
Parameter name: byteCount
at System.Text.ASC IIEncoding.GetC hars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at System.Text.Def aultDecoder.Get Chars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at System.IO.Strea mReader.ReadBuf fer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffe r)
at System.IO.Strea mReader.Read(Ch ar[] buffer, Int32 index, Int32 count)
at WebCleaner.WebC leaner.ReadResp (Stream stream, Encoding encoding, Boolean print, Boolean stop)
regards,
bullshark
iteration of the (same) object and the code below is used 5 times
per iteration giving 1335 cycles. It was halfway through current
iteration at fail.
The raised exception (see below) does not seem to be documented
or under my control. It appears that methods internal to the
StreamReader class have failed.
Any idea if this is a bug or known problem?
string ReadResp(Stream stream,Encoding encoding,bool print, bool stop){
StreamReader reader=new StreamReader(st ream,encoding);
char[] read=new char[256];
int count;
StringBuilder str=new StringBuilder(" ");
count=reader.Re ad(read,0,256); //Exception thrown here
while(count > 0){
str.Append(read );
count=reader.Re ad(read,0,256); // Or here...
}
response=str.To String();
if( print )
Console.WriteLi ne(response);
if(stop){
Console.WriteLi ne("Press Enter to continue.");
Console.ReadLin e();
}
return response;
}
Main Exception raised!
Source :mscorlib
Message :Non-negative number required.
Parameter name: byteCount
at System.Text.ASC IIEncoding.GetC hars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at System.Text.Def aultDecoder.Get Chars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at System.IO.Strea mReader.ReadBuf fer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffe r)
at System.IO.Strea mReader.Read(Ch ar[] buffer, Int32 index, Int32 count)
at WebCleaner.WebC leaner.ReadResp (Stream stream, Encoding encoding, Boolean print, Boolean stop)
regards,
bullshark