byte[] to binary(16) throwing IndexOutOfRangeException
Posted by: Firstiar Noorwinanto
Date: October 28, 2016 06:29AM

Hello,
I have a model with byte[] property that always contain 16 element of byte. The corresponding table has a column with type of binary(16).

Whenever I want to insert new record, it always throwing IndexOutOfRangeException: Index was outside the bounds of the array.

It was thrown by MySql.Data.Types.MySqlBinary.EscapeByteArray(Byte[] bytes, Int32 length, MySqlPacket packet). Here are the stack traces:


---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at MySql.Data.Types.MySqlBinary.EscapeByteArray(Byte[] bytes, Int32 length, MySqlPacket packet)
at MySql.Data.Types.MySqlBinary.MySql.Data.Types.IMySqlValue.WriteValue(MySqlPacket packet, Boolean binary, Object val, Int32 length)
at MySql.Data.MySqlClient.MySqlParameter.Serialize(MySqlPacket packet, Boolean binary, MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
at MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
at MySql.Data.MySqlClient.Statement.BindParameters()
at MySql.Data.MySqlClient.PreparableStatement.Execute()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean openConnection, Boolean closeConnection)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues, Boolean manageConnection)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
--- End of inner exception stack trace ---

Any idea what cause this exception?

Options: ReplyQuote


Subject
Written By
Posted
byte[] to binary(16) throwing IndexOutOfRangeException
October 28, 2016 06:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.