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 MySqlC开发者_JAVA百科onnection(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?
I have this working using the lastest connector for .NET/Mono found here.
- Add mysql.data.dll (zip path mysql-connector-net-6.4.4-noinstall/v4) to project references;
- Web.Config changes: http://pastebin.com/CsHzwR4M.
精彩评论