mysql:定义了类型“marshallbyvaluecomponent”

6tdlim6h  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(306)

这是我调用数据库的代码:

using System;
using System.Collections.Generic;
using System.Data;
using System.Threading;
using GTANetworkAPI;
using MySql.Data.MySqlClient;

public static DataTable ExecuteQueryWithResult(string sql, bool isRecconect = false)
{
    using (var conn = new MySqlConnection(_connStr))
    {
        try
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();
            DataTable results = new DataTable();
            results.Load(rdr);
            rdr.Close();
            conn.ClearAllPoolsAsync();
            conn.CloseAsync();
            return results;
        }
        catch (Exception ex)
        {
            API.Shared.ConsoleOutput("DATABASE: [ERROR] " + ex);
        }
    }

    if(isRecconect)
        return new DataTable();

    Thread.Sleep(5000);
    return ExecuteQueryWithResult(sql, true);
}

但我现在有个例外 conn.Open :
cs0012:在未引用的程序集中定义了类型“marshalbyvaluecomponent”。必须添加对程序集“system.componentmodel.typeconverter,version=4.2.0.0,culture=neutral,publickeytoken=b03f5f7f11d50a3a”的引用。->服务器/mysql.cs:36
参考文献:https://i.imgur.com/g89mblm.png
代码:https://i.imgur.com/e8jffvc.png

暂无答案!

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

相关问题