P
Petar Popara
I have this case:
int bufferLen = Convert.ToInt32(file.Length);
char[] buffer = new char[bufferLen];
int len = sr.Read(buffer, 0, bufferLen);
rawBytes.setBytesArray(buffer);
While executing above code I got this (COM, automation) error at last line:
An unhandled exception of type
'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in
MyApp.exe
That is because buffer have to be of byte[] type and not char[]. But, if I
change "buffer" to byte[] than I got compiler error saying that sr.Read() is
expecting char[] instead of byte[].
What should I do? Cast? How? Something like this:
int len = sr.Read((char[])buffer, 0, bufferLen);
int bufferLen = Convert.ToInt32(file.Length);
char[] buffer = new char[bufferLen];
int len = sr.Read(buffer, 0, bufferLen);
rawBytes.setBytesArray(buffer);
While executing above code I got this (COM, automation) error at last line:
An unhandled exception of type
'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in
MyApp.exe
That is because buffer have to be of byte[] type and not char[]. But, if I
change "buffer" to byte[] than I got compiler error saying that sr.Read() is
expecting char[] instead of byte[].
What should I do? Cast? How? Something like this:
int len = sr.Read((char[])buffer, 0, bufferLen);