c# - MySQLConnection 在 Visual Studio 中抛出异常

标签 c# mysql visual-studio-2017

我不知道我的 MySql.Data 发生了什么,为什么在我打开连接时它总是遇到错误。

using MySql.Data.MySqlClient;

MySqlConnection myconn = new MySqlConnection();
myconn.ConnectionString = "server=192.168.0.xxx;port=3306;database=db_name;user id=root;password=pass123";
if (myconn.State == ConnectionState.Closed)
     myconn.Open();

然后在 myconn.Open(); 之后到达。

enter image description here

我正在堆栈中搜索该特定错误,但没有看到任何答案。

PS: MySqlConnection 的代码昨天运行的很好,但是不知道为什么会出现刚才的错误。

PPS :我在不同的项目中尝试了 MySqlConnection 的代码,它也工作正常,但当涉及到我的真实项目时,它不起作用。

最佳答案

最近,我对我的项目进行了一些修改

喜欢:

  • 添加和删除一些应用程序设置
  • 将 .Net Framework 版本从 4.0 更改为 4.6.1,反之亦然。

在发生错误时进行了多次修改。 我认为正因为如此,MySqlConnection 受到了影响并且无法正常工作。

现在我不知道为什么或如何,但我通过将程序集信息从 1.0.0.0 更改为 1.0.1.0 解决了我的问题。 更 retrofit 配信息将 cause the compiler to reevaluate the configuration and cause the application to refrain from creating and reading a new user.config file corresponding to the new version due to there being no user settings in the new version.

关于c# - MySQLConnection 在 Visual Studio 中抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46903843/

相关文章:

c# - 有没有办法从 StreamReader 中删除第一行

C# 返回组合异常

c# - 我试图理解我反射(reflect)过的微软的 Do​​ubleUtil.AreClose() 代码

c# - 你如何创建一个类似守护进程的应用程序来接收来自 Windows 服务的信息?

php - Laravel:更新 hasMany/BelongsTo 关系

java - ResultSet.TypeForwardOnly 和 Result Set.Type Scrollable 之间的区别

php - 从 mySQL JOIN 语句返回重复值。帮助?

c++ - 为什么这个 get_index 实现在 VS2017 上失败了?

.net - Visual Studio 2017 - 无法加载文件或程序集 'System.Runtime, Version=4.1.0.0' 或其依赖项之一

c# - 显示调试器未显示在 Visual Studio 2017 中