Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug MySqlConnectionStringBuilder error with IL2CPP

Discussion in 'Formats & External Tools' started by Khelgar, Apr 21, 2021.

  1. Khelgar

    Khelgar

    Joined:
    Mar 13, 2019
    Posts:
    16
    Hi everyone,

    In my scene I have to do a connection to a MySQL database. When I play my scene on Unity Editor, PC standalone build or Android build it's working fine, but after compiling with Xcode I have the following issue :

    Code (CSharp):
    1. NotSupportedException: Method body replaced by UnityLinker.exe with a NotSupportedException
    2.   at System.Data.DataCommonEventSource.Trace (System.String message) [0x00000] in <00000000000000000000000000000000>:0
    3.   at System.Data.Common.DbConnectionStringBuilder.Clear () [0x00000] in <00000000000000000000000000000000>:0
    4.   at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.Clear () [0x00000] in <00000000000000000000000000000000>:0
    5.   at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString (System.String value) [0x00000] in <00000000000000000000000000000000>:0
    6.   at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor (System.String connStr) [0x00000] in <00000000000000000000000000000000>:0
    7.   at MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString (System.String value) [0x00000] in <00000000000000000000000000000000>:0
    8. (Filename: currently not available on il2cpp Line: -1)
    And there is my code :

    Code (CSharp):
    1.         m_Connection = new MySqlConnection();
    2.         MySqlConnectionStringBuilder connectionBuilder = new MySqlConnectionStringBuilder();
    3.         connectionBuilder.Server = m_ServerAdress; // xxx.xxx.xxx.xxx
    4.         connectionBuilder.Database = m_DatabaseName;
    5.         connectionBuilder.UserID = m_UserID;
    6.         connectionBuilder.Password = m_UserPassword;
    7.         m_Connection.ConnectionString = connectionBuilder.ConnectionString; // exception is thrown here
    I tried to do this code part with differents ways like m_Connection = new MySqlConnection(string);
    I also tried to change the version of MySQL connector.

    Someone have an idea to fix this issue ?
    Thanks for any help.

    EDIT 1 : This problem is also present with an Android Build when I use IL2CPP as Scripting Backend.

    EDIT 2 : I'm using .Net & Mono MySQL connector and building with IL2CPP scripting backend, not Mono. But with iOS we must use IL2CPP and we can't use Mono.

    I'm using Unity 2019.4 and MySQL connector .Net & Mono 6.9.5.
     
    Last edited: Apr 26, 2021