Home  >  Q&A  >  body text

.NET Framework does not support character set 'utf8mb3': System.NotSupportedException

I'm trying to run a server with a MySQL database, but I keep getting this huge error and I don't know why.

[21:15:49,107] Server Properties Lookup: Error While Initialization
DOL.Database.DatabaseException: Table DOL.Database.ServerProperty is not registered for Database Connection...
   at DOL.Database.ObjectDatabase.SelectAllObjects[TObject]()
   at DOL.GS.ServerProperties.Properties.get_AllDomainProperties()
   at DOL.GS.ServerProperties.Properties.InitProperties()
   at DOL.GS.GameServer.InitComponent(Action componentInitMethod, String text)```

also this error

[21:15:35,991] ExecuteSelectImpl: UnHandled Exception for Select Query "DESCRIBE `Specialization`"
System.NotSupportedException: Character set 'utf8mb3' is not supported by .Net Framework.
   at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet(DBVersion version, String charSetName)
   at MySql.Data.MySqlClient.MySqlField.SetFieldEncoding()
   at MySql.Data.MySqlClient.NativeDriver.GetColumnData(MySqlField field)
   at MySql.Data.MySqlClient.NativeDriver.GetColumnsData(MySqlField[] columns)
   at MySql.Data.MySqlClient.Driver.GetColumns(Int32 count)
   at MySql.Data.MySqlClient.ResultSet.LoadColumns(Int32 numCols)
   at MySql.Data.MySqlClient.ResultSet..ctor(Driver d, Int32 statementId, Int32 numCols)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at MySql.Data.MySqlClient.MySqlCommand.ResetReader()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader()
   at DOL.Database.SQLObjectDatabase.ExecuteSelectImpl(String SQLCommand, IEnumerable`1 parameters, Action`1 Reader)```


P粉063039990P粉063039990366 days ago852

reply all(2)I'll reply

  • P粉647449444

    P粉6474494442023-10-20 17:11:15

    There are updates/NET available for the MySQL connector.

    After updating to version 8.0.28 (NuGet package MySql.Data) everything is back to normal.

    reply
    0
  • P粉683665106

    P粉6836651062023-10-20 12:08:27

    In my case, I installed 10.6.4-MariaDB with utf8mb3 by default.

    I got the same error when trying to read the table.

    I fixed the issue by changing all character set settings in the MariaDB configuration to utf8mb4.

    Then dump my database and import it again. This time specify utf8mb4 when creating the database.

    So, normal SELECT, UPDATE queries work fine and no more errors occur.

    But when my application calls the stored procedure, I keep getting errors.

    I think this may be because the stored procedure saves to the information_schema database, which is still utf8mb3 and I can't find a way to change it to >utf8mb4.

    After spending a lot of time trying to implement some weird workarounds, I came across this bug report:

    Unable to use MariaDB 10.6 from a C# client application:
    https://jira.mariadb.org/browse/MDEV-26105?attachmentViewMode=List

    A user there said:

    MySqlCommand setcmd = new MySqlCommand("SET character_set_results=utf8", conn);
    int n = setcmd.ExecuteNonQuery();
    setcmd.Dispose();

    So I ended up adding this to my VB project before executing the stored procedure:

    Dim sqlCommand As New MySqlCommand
    sqlCommand.Connection = _MySqlCn
    sqlCommand.CommandText = "SET character_set_results=utf8"
    sqlCommand.ExecuteNonQuery()

    This solved the error for me.

    Also, here is what I changed previously in the MariaDB server configuration:

    [client]
    default-character-set=utf8mb4
    
    [mysql]
    default-character-set=utf8mb4
    
    # this is read by the standalone daemon and embedded servers
    [server]
    
    # this is only for the mysqld standalone daemon
    [mysqld]
    
    old_mode=
    character-set-server = utf8mb4
    character-set-client=utf8mb4
    collation-server = utf8mb4_unicode_520_ci
    init-connect='SET NAMES utf8mb4'

    reply
    0
  • Cancelreply