为什么 MySql Connector.Net 在我的 Windows 机器上可以工作,但在 Mono 上却不行?
我已经安装了 Mono(版本 2.10.2)、mod_mono 并已成功使用与日期相呼应的 index.html 和 index.aspx 对其进行了测试。
我的问题是我无法让 MySQL 与 Mono 一起工作;
我已经下载了 mysql-connector-net-6.4.3-noinstall.zip 文件, 将 dll 重命名为 MySql.Data.dll,(来自 v2 文件夹)
我已使用 gacutil -i MySql.Data.dll 安装 并编辑了两个 machine.config 文件(适用于 2.0 和 4.0),添加以下内容:
<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 的大小写为小写。
我的索引页后面有这段代码:
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 机器上运行它时,出现以下错误:
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
我该如何解决这个问题?有人遇到过类似的事情吗?
作为一种解决方案,我正在考虑使用 ODBC 驱动程序来访问 MySQL,而不是单声道驱动程序。这可以做到吗?
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.
My problem is that I can't get MySQL to work with Mono;
I have downloaded the mysql-connector-net-6.4.3-noinstall.zip file,
renamed the dll to MySql.Data.dll, (from v2 folder)
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" />
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);
}
}
}
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?
As a solution am thinking about using the ODBC driver to access MySQL instead of the mono one. Can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 此处 找到的最新的 .NET/Mono 连接器进行此工作。
I have this working using the lastest connector for .NET/Mono found here.