我已经确定MySQL的所有三个版本(来自NuGet)都是相同的。我有一个可执行文件和两个库。我有可执行文件'botLoader',库'botLoaderAPI'和'logBot'。我有一个方法可以设置一些机器人数据,同时传递一个MySQL连接,这样就可以存储东西。
logBot:
namespace logBot
{
class Bot : IBot
{
private MySqlConnection _sqlconn;
public string RaiseBot(MySqlConnection connToBeUsed, string[] configurationDetails)
{
_sqlconn = connToBeUsed;
/* rest of the code, but the above is the only mention of it for this method */
}
}
}
botLoaderAPI:
namespace botLoaderAPI
{
public class BotHolder
{
private Type _type;
private Object _instance;
private MethodInfo _raiseBotMethod;
public void _setTypeAndMethods(Type type)
{
_type = type;
_instance = Activator.CreateInstance(_type);
_raiseBotMethod = _type.GetMethod("RaiseBot");
}
public string RaiseBot(MySqlConnection conn, string[] configDetails)
{
return _raiseBotMethod.Invoke(_instance, new Object[2] { conn, _configDetails}).ToString();
}
}
}
当我运行botLoader并传递MySQL连接(确认它有效)时,我得到以下异常:
- InnerException {"Object of type 'MySql.Data.MySqlClient.MySqlConnection' cannot be converted to type 'MySql.Data.MySqlClient.MySqlConnection'."} System.Exception {System.ArgumentException}