4
votes

I'm starting to develop some applications using mono and MySQL. While experimenting with those tools I tried to use the Connecotr/net of MySql. I've downloaded the latest version and installed it like told in the documentation.

I've created a small console application for testing connecting to MySQL. Here is the few lines of Code I used:

public static void Main (string[] args)
{
    string connString = "Server=localhost;Database=feuerwehr;Uid=XXX;Pwd=XXX;";
    MySqlConnection conn = new MySqlConnection (connString);
    try {
        Console.WriteLine ("Connection to MySQL ...");
        conn.Open ();
    } catch (Exception ex) {
        Console.WriteLine (ex.Message);
    }
    conn.Close ();
    Console.WriteLine ("Done!");
}

There is no problem to build the application. But when I run it, there comes this error:

Missing method .ctor in assembly /Users/Patrick/Projects/MySqlTest2/MySqlTest2/bin/Debug/MySql.Data.dll, type System.Security.SecurityRulesAttribute Can't find custom attr constructor image: /Users/Patrick/Projects/MySqlTest2/MySqlTest2/bin/Debug/MySql.Data.dll mtoken: 0x0a00002b

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Security.SecurityRulesAttribute' from assembly 'MySql.Data'. at MySqlTest2.MainClass.Main (System.String[] args) [0x00006] in /Users/Patrick/Projects/MySqlTest2/MySqlTest2/Main.cs:12

Did anyone of you have this problem also? Were you able to resolve it?

I want my application to run on different platforms and also should be able to update different clients, which each has its own database, over the internet. So I decided to use Mono and MySQL. If anyone knows any better database for this task this may also be an option. I don't want to use Java or any other programming language, because I've got some experience with developing .net applications on Windows.

Thanks for helping me!

1
Are you using the latest version (6.4.4) for mono?Rui Marques

1 Answers

6
votes

SecurityRulesAttribute class is specific to .NET v4.0, make sure your project is built for that runtime version. By default MonoDevelop builds for .NET v3.5 I think.