Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug MySqlConnectionStringBuilder error with IL2CPP

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

  1. Khelgar


    Mar 13, 2019
    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; //
    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