Skip to content

Conversation

@rostov114
Copy link

This error may occur when using the latest versions of MariaDB.

MySql handle raised an exception (InvalidCastException: Object cannot be cast from DBNull to other types.)
  at System.DBNull.System.IConvertible.ToInt32 (System.IFormatProvider provider) [0x00000] in <2161c9885dd04ff291b79db9349c4b9b>:0 
  at System.Convert.ToInt32 (System.Object value, System.IFormatProvider provider) [0x00003] in <2161c9885dd04ff291b79db9349c4b9b>:0 
  at MySql.Data.MySqlClient.Driver.LoadCharacterSets (MySql.Data.MySqlClient.MySqlConnection connection) [0x00079] in <8d7380b3d3cf4bd8be324c584f371b44>:0 
  at MySql.Data.MySqlClient.Driver.Configure (MySql.Data.MySqlClient.MySqlConnection connection) [0x00060] in <8d7380b3d3cf4bd8be324c584f371b44>:0 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00198] in <8d7380b3d3cf4bd8be324c584f371b44>:0 
  at Oxide.Core.MySql.Libraries.MySql+MySqlQuery.Handle () [0x00059] in <021a1dba6a754e42a6cc7771fdfee190>:0 

Due to the presence of charsets without Id

SHOW COLLATION result:

| uca1400_ai_ci                  | NULL     | NULL | NULL    | Yes      |       8 |
| uca1400_ai_cs                  | NULL     | NULL | NULL    | Yes      |       8 |
| uca1400_as_ci                  | NULL     | NULL | NULL    | Yes      |       8 |
| uca1400_as_cs                  | NULL     | NULL | NULL    | Yes      |       8 |
| uca1400_nopad_ai_ci            | NULL     | NULL | NULL    | Yes      |       8 |
...

Add condition in Driver.LoadCharacterSet over DnSpy

if (mySqlDataReader["id"] != DBNull.Value)
{
	this.charSets[Convert.ToInt32(mySqlDataReader["id"], NumberFormatInfo.InvariantInfo)] = mySqlDataReader.GetString(mySqlDataReader.GetOrdinal("charset"));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant