mysql连接值不能为空参数名称:类型

4urapxun  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(233)

当我运行下面的代码时,在运行时出现以下错误:
值不能为空。参数名称:类型
这里有一个完全的例外:

MySql.Data.MySqlClient.MySqlException: Unable to create plugin for authentication method 'mysql_native_password'. 
Please see inner exception for details. --->
System.ArgumentNullException: Value cannot be null.
Parameter name: type
   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00006] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/activator.cs:192 
   at System.Activator.CreateInstance (System.Type type) [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/activator.cs:134 
   at MySql.Data.MySqlClient.Authentication.AuthenticationPluginManager.CreatePlugin (System.String method) [0x00019] in <4adf5733b5f24682b339d246b115a2af>:0 
    --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.Authentication.AuthenticationPluginManager.CreatePlugin (System.String method) [0x0003c] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.Authentication.AuthenticationPluginManager.GetPlugin (System.String method) [0x0001e] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.GetPlugin (System.String method, MySql.Data.MySqlClient.NativeDriver driver, System.Byte[] authData) [0x0001f] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, System.Boolean reset) [0x00029] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.NativeDriver.Open () [0x00223] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.Driver.Open () [0x0000b] in <4adf5733b5f24682b339d246b115a2af>:0 
   at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00027] in <4adf5733b5f24682b339d246b115a2af>:0

打开连接时出错。
这是我的密码:

public string connString()
{
    MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
    builder.Server = "localhost";
    builder.Port = 3306;
    builder.UserID = "root";
    builder.Password = "root1234";
    builder.Database = "tips-db";
    return builder.ToString();
}

public bool Connect()
{
    conn = new MySqlConnection();
    conn.ConnectionString = connString();
    try
    {
        conn.Open();
    }
    catch (Exception e)
    {
        Toast.MakeText(Application.Context, e.InnerException.Message, ToastLength.Long).Show();
        conn.Close();
        return false;
    }
    conn.Close();
    return true;
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题