D
Denis C
Hi,
I posted this earlier today with no help. I'm trying
agin as I am desparate(sp?).
Hi there,
I'm trying to convert part of a byte array into a series
of fixed length strings but half way through the for loop
I get an error that I'm accessing outside the buffer
bounds.
The error:
An unhandled exception of
type 'System.ArgumentOutOfRangeException' occurred in
mscorlib.dll
Additional information: Index and count must refer to a
location within the buffer.
The loop:
Private Sub initAttribText(ByVal bData() As Byte)
Dim pos As Integer = charSize * 100
For i As Integer = 0 To 39
theAttribText(i) = _
System.Text.ASCIIEncoding.ASCII.GetString
(bData, arrayStart + (i * pos),
(arrayStart + (i * pos)) + 99)
Next i
arrayStart += (40 * pos)
End Sub
The byte array bData is of length 4481.
The value of i at the point of the error is 21.
The value of arrayStart is 160.
The value of pos is 100.
So the indexes at the point of the error are 2260, 2359.
IF anyone can tell me the cause of the error I would be
very greatful!! Clearly the indexes are within the bounds
of the byte array so there must be some other cause but I
can't see it.
Thanks,
Denis
..
The byte array comes is marshalled from an IntPtr. The
IntPtr is returned by a C dll function that I have access
using the DllImportAttribute class.
Any help would be really appreciated. Unfortunately I
cannot post much more code than this. But I can say this
is the only case that htis approach is not working. For
Accessing integer arrays and boolean arrays I am having
no problems.
Denis
I posted this earlier today with no help. I'm trying
agin as I am desparate(sp?).
Hi there,
I'm trying to convert part of a byte array into a series
of fixed length strings but half way through the for loop
I get an error that I'm accessing outside the buffer
bounds.
The error:
An unhandled exception of
type 'System.ArgumentOutOfRangeException' occurred in
mscorlib.dll
Additional information: Index and count must refer to a
location within the buffer.
The loop:
Private Sub initAttribText(ByVal bData() As Byte)
Dim pos As Integer = charSize * 100
For i As Integer = 0 To 39
theAttribText(i) = _
System.Text.ASCIIEncoding.ASCII.GetString
(bData, arrayStart + (i * pos),
(arrayStart + (i * pos)) + 99)
Next i
arrayStart += (40 * pos)
End Sub
The byte array bData is of length 4481.
The value of i at the point of the error is 21.
The value of arrayStart is 160.
The value of pos is 100.
So the indexes at the point of the error are 2260, 2359.
IF anyone can tell me the cause of the error I would be
very greatful!! Clearly the indexes are within the bounds
of the byte array so there must be some other cause but I
can't see it.
Thanks,
Denis
..
The byte array comes is marshalled from an IntPtr. The
IntPtr is returned by a C dll function that I have access
using the DllImportAttribute class.
Any help would be really appreciated. Unfortunately I
cannot post much more code than this. But I can say this
is the only case that htis approach is not working. For
Accessing integer arrays and boolean arrays I am having
no problems.
Denis