Bug #89560 MySql.Data, MySqlConnection, Unhandled Exception.
Submitted: 7 Feb 2018 1:16 Modified: 9 Feb 2018 0:48
Reporter: qining luo Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.10-rc OS:Ubuntu (16.04LTS)
Assigned to: CPU Architecture:Any
Tags: exception, initializer, MySql.Data, MySqlConnection, ReplicationManager

[7 Feb 2018 1:16] qining luo
Description:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception. ---> System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId)
   at System.Uri.CreateHostString()
   at System.Uri.EnsureHostString(Boolean allowDnsOptimization)
   at System.Uri.GetComponentsHelper(UriComponents uriComponents, UriFormat uriFormat)
   at System.Uri.ToString()
   at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(String exePath)
   at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
   at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
   at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
   at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at MySql.Data.MySqlClient.MySqlConfiguration..cctor()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.MySqlConfiguration.get_Settings()
   at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.Replication.ReplicationManager.IsReplicationGroup(String groupName)
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at mysqltest1.Program.Main(String[] args) in /home/lqn/test/mysqltest1/Program.cs:line 24

How to repeat:
OS:Ubuntu 16.04 LTS
Dotnet SDK : 2.1.4 
MySql.Data : 8.0.10-rc
MySql      : 5.7.21-0ubuntu0.16.04.1

Test code:

using System;
using MySql.Data.MySqlClient;
namespace mysqltest1
{
    class Program
    {
        static void Main(string[] args)
        {
			MySqlConnectionStringBuilder b = new MySqlConnectionStringBuilder();
			b.Server = "localhost";
			b.Port = 3306;
			b.Database = "testdb";
			b.UserID = "root";
			b.Password = "123456";
			b.CharacterSet = "utf8";
			var connstr = b.ToString();
			MySqlConnection conn = new MySqlConnection(connstr);
			conn.Open();
			conn.Close();
        }
    }
}

dotnet run
[7 Feb 2018 11:53] Chiranjeevi Battula
Hello qining luo,

Thank you for the bug report and testcase.
I could not repeat the issue at our end using with Visual Studio 2017, Connector/NET 8.0.10-rc version.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.
[7 Feb 2018 11:54] Chiranjeevi Battula
Screenshot

Attachment: Bug_89560.PNG (image/png, text), 60.38 KiB.

[8 Feb 2018 0:48] qining luo
Thank you for the replay.
I found that you test it on WINDOWS, yes it is ok on WINDOWS. But it not work on LINUX of UBUNTU. 
So please try again in LINUX os.

OS:Ubuntu 16.04 LTS
Dotnet SDK : 2.1.4 
MySql.Data : 8.0.10-rc
MySql      : 5.7.21-0ubuntu0.16.04.1
[8 Feb 2018 0:56] qining luo
Exception on ubuntu

Attachment: Image 1.png (image/png, text), 166.54 KiB.

[9 Feb 2018 0:48] qining luo
This bug onle happened on Linux os.