为什么 MySql Connector.Net 在我的 Windows 机器上可以工作,但在 Mono 上却不行?

发布于 2024-12-05 20:20:57 字数 1781 浏览 0 评论 0原文

我已经安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你另情深 2024-12-12 20:20:57

我使用 此处 找到的最新的 .NET/Mono 连接器进行此工作。

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

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

  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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文