12-25-2021, 10:53 PM
Hi,
I am transferring byte arrays from .Net to Delphi. This operation is repeated thousands of times and the length of the byte array is beteeen 5k and 500k. The operations runs without issues for a couple of minutes but then crashes on the .Net side with the following error:
System.OverflowException
HResult=0x80131516
Message=Arithmetic operation resulted in an overflow.
Source=Atozed.CrossTalk.Right
StackTrace:
at Atozed.CrossTalk.Right.CTStreamReader.Read() in Atozed.CrossTalk.Right\CTStreamReader.cs:line 67
This exception was originally thrown at this call stack:
Atozed.CrossTalk.Right.CTStreamReader.Read() in CTStreamReader.cs
On the Delphi side I am using ByteArray.AsDelphiArray to get the bytes. The exception is happening when this method is called.
If I take the same byte array which causes this and transfer it in isolation (e.g. without making any other transfers beforehand) then everything works fine. So the error is caused by repeating the operation many times with different arrays.
I have already tried to use CopyToDelphiArray instead but it yields the same error.
I have also added a logic which catches this error and reverts to use a for loop to get the bytes from the ByteArray by index. This works but unacceptable slow. Note that once the exception was thrown AsDelphiArray only works for a couple of calls and then the same exception is thrown.
I am transferring byte arrays from .Net to Delphi. This operation is repeated thousands of times and the length of the byte array is beteeen 5k and 500k. The operations runs without issues for a couple of minutes but then crashes on the .Net side with the following error:
System.OverflowException
HResult=0x80131516
Message=Arithmetic operation resulted in an overflow.
Source=Atozed.CrossTalk.Right
StackTrace:
at Atozed.CrossTalk.Right.CTStreamReader.Read() in Atozed.CrossTalk.Right\CTStreamReader.cs:line 67
This exception was originally thrown at this call stack:
Atozed.CrossTalk.Right.CTStreamReader.Read() in CTStreamReader.cs
On the Delphi side I am using ByteArray.AsDelphiArray to get the bytes. The exception is happening when this method is called.
If I take the same byte array which causes this and transfer it in isolation (e.g. without making any other transfers beforehand) then everything works fine. So the error is caused by repeating the operation many times with different arrays.
I have already tried to use CopyToDelphiArray instead but it yields the same error.
I have also added a logic which catches this error and reverts to use a for loop to get the bytes from the ByteArray by index. This works but unacceptable slow. Note that once the exception was thrown AsDelphiArray only works for a couple of calls and then the same exception is thrown.