con.open() error in visual studio 2019 if want to connect with mysql

0
System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception.
  Source=MySql.Data
  StackTrace:
   at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at db4.Form1.button1_Click(Object sender, EventArgs e) in D:\C# GUI\db4\db4\Form1.cs:line 27
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

I have installed the connector below one https://dev.mysql.com/downloads/connector/net/ but not working I am using the 5.0 framework

this is the screenshot of the error in visual

c#
asked on Stack Overflow Mar 15, 2021 by Jawad Liaqat

1 Answer

-1

Have you tried with the following installation?

PM> Install-Package MySqlConnector -Version 1.3.1

This could be a workaround!

answered on Stack Overflow Mar 15, 2021 by Salahuddin Ahmed

User contributions licensed under CC BY-SA 3.0