C
Claire
This works ok in a new empty project. I write an empty string to a file.
Looking at the file with a hex editor, there's a single byte of value zero.
I expect this, it's utf8 encoding and this is the leading length byte.
In my "real" project I have the following code. The first MessageBox tells
me that the stream position is correct for reading this single byte. The 2nd
message box tells me that the byte count is zero for an empty string (is
this correct?. doesn't it count the leading length 7 bit char counter?)
The 4th line (line 137) is where my code falls over, as I get the exception
"System.NullReferenceException: Object reference not set to an instance of
an object.
at jfmcommsservice.PPC_Converter.ConvertUpload(FileEventArgs e, Tour tour)
in blah blah blah line 137
blah blah"
Is there an obvious problem here? Can using encoding elsewhere change things
for the rest of the application?
BinaryReader reader = new BinaryReader(e.memorystream);
System.Windows.Forms.MessageBox.Show(reader.BaseStream.Position.ToString());
System.Windows.Forms.MessageBox.Show(System.Text.Encoding.UTF8.GetByteCount("").ToString());
mm.Result.Comment = reader.ReadString();
Looking at the file with a hex editor, there's a single byte of value zero.
I expect this, it's utf8 encoding and this is the leading length byte.
In my "real" project I have the following code. The first MessageBox tells
me that the stream position is correct for reading this single byte. The 2nd
message box tells me that the byte count is zero for an empty string (is
this correct?. doesn't it count the leading length 7 bit char counter?)
The 4th line (line 137) is where my code falls over, as I get the exception
"System.NullReferenceException: Object reference not set to an instance of
an object.
at jfmcommsservice.PPC_Converter.ConvertUpload(FileEventArgs e, Tour tour)
in blah blah blah line 137
blah blah"
Is there an obvious problem here? Can using encoding elsewhere change things
for the rest of the application?
BinaryReader reader = new BinaryReader(e.memorystream);
System.Windows.Forms.MessageBox.Show(reader.BaseStream.Position.ToString());
System.Windows.Forms.MessageBox.Show(System.Text.Encoding.UTF8.GetByteCount("").ToString());
mm.Result.Comment = reader.ReadString();