0

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?

Farray
  • 8,290
  • 3
  • 33
  • 37
sergio
  • 1,026
  • 2
  • 19
  • 43
  • You didn't say anything about referencing the MySql.Data.dll in your project. Have you done this? I've found that installing the dll in the GAC does NOT mean you can run your program without a local copy of the dll. Also, I know the latest versions of MySql.Web.dll require the .NET 4.0 framework. I'm not sure if MySql.Data.dll requires the same, but it's something to try. – qxn Jan 02 '12 at 19:47

1 Answers1

0

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.
Rui Marques
  • 3,429
  • 1
  • 22
  • 26