为什么MySql Connector.Net可以在Windows机器上运行,而不能在Mono上运行? [英] Why does MySql Connector.Net work on my Windows box but not on Mono?

查看:102
本文介绍了为什么MySql Connector.Net可以在Windows机器上运行,而不能在Mono上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Mono(版本2.10.2),mod_mono,并已通过index.html和index.aspx回显日期的方式成功对其进行了测试.

I have installed Mono (version 2.10.2), mod_mono and have successfully tested it with both an index.html and an index.aspx echoing the date.

我的问题是我无法让MySQL与Mono合作;

My problem is that I can't get MySQL to work with Mono;

我已经下载了mysql-connector-net-6.4.3-noinstall.zip文件, 将dll重命名为MySql.Data.dll(从v2文件夹)

I have downloaded the mysql-connector-net-6.4.3-noinstall.zip file, renamed the dll to MySql.Data.dll, (from v2 folder)

我已经安装了gacutil -i MySql.Data.dll 并编辑了两个machine.config文件(适用于2.0和4.0),并添加了以下内容:

I have installed with gacutil -i MySql.Data.dll and edited both machine.config files (for 2.0 and 4.0) adding the following:

<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" 
     description=".Net Framework Data Provider for MySQL" 
     type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

然后我编辑了web.config文件,以确保PublicKeyToken是小写字母.

I then edited the web.config file to make sure the PublicKeyToken was lowered case.

我的索引页中有以下代码:

My index page that has this code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace gpsmapper {

public partial class login : System.Web.UI.Page {

    protected void Page_Load(object sender, EventArgs e) {}

    protected void cmdLogin_Click(object sender, EventArgs e){
        string cs = "Server=localhost;" + "Database=gts;" + "User ID=root;" + "Password=root;" 
+ "Pooling=false";
        MySqlConnection dbcon = new MySqlConnection(cs);
    }
    }
}

这一切在Windows上都可以正常运行,但最终将部署在CentOS机器上.当我在CentOS盒子上运行它时,出现以下错误:

This all runs fine on Windows, but it will ultimately be deployed on a CentOS box. When I run it on the CentOS box it gives me the following error:

Compilation Error

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Compiler Error Message: : at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0
/gpsmapper/login.aspx

我该如何解决?有没有人遇到过类似的事情?

How can I solve this? Has anyone faced something similar?

作为一种解决方案,我正在考虑使用ODBC驱动程序而不是单声道驱动程序来访问MySQL.能做到吗?

As a solution am thinking about using the ODBC driver to access MySQL instead of the mono one. Can this be done?

推荐答案

我使用最新的.NET/Mono连接器进行此工作,发现它是

I have this working using the lastest connector for .NET/Mono found here.

  1. mysql.data.dll (zip路径 mysql-connector-net-6.4.4-noinstall/v4 )添加到项目引用中;
  2. Web.Config 的更改: http://pastebin.com/CsHzwR4M .
  1. Add mysql.data.dll (zip path mysql-connector-net-6.4.4-noinstall/v4) to project references;
  2. Web.Config changes: http://pastebin.com/CsHzwR4M.

这篇关于为什么MySql Connector.Net可以在Windows机器上运行,而不能在Mono上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆