c# - 如果想连接 mysql,Visual Studio 2019 中的 con.open() 错误
问题描述
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.
我已经在一个 https://dev.mysql.com/downloads/connector/net/下面安装了连接器, 但没有工作我使用的是 5.0 框架
解决方案
您是否尝试过以下安装?
PM> Install-Package MySqlConnector -Version 1.3.1
这可能是一种解决方法!
推荐阅读
- r - 将值与列名匹配以在 R 中创建新变量
- javascript - 我们如何在 Handlebar js 中使用 if 和 else if 条件比较两个或多个值
- html - 如何引用两个样式表
- javascript - 如何检查单击的元素也具有 x 类?
- javascript - javascript:获取不重复的随机数组对
- java - TOMCAT Eclipse 本地主机调用 webservice SOAP rpc TLS 1.2
- web-crawler - 为什么 Bing 爬虫无法获取我的 Angular 网页的动态内容?
- php - 从 PHP 中的数组取平均值
- json - Angular 5“未定义地图”
- python - 将 traceback.format_exc() 附加到列表中就是将“\”添加到单引号 (')