我开始使用mono和MySQL开发一些应用程序.
在尝试使用这些工具时,我尝试使用Connecotr / net of MySql.我已经下载了最新版本并按照文档中的说明进行了安装.
我已经创建了一个小型控制台应用程序来测试连接到MySQL.
以下是我使用的几行代码:
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!");
}
构建应用程序没有问题.但是当我运行它时,出现了这个错误:
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: 0x0a00002bUnhandled 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
你们有没有人也有这个问题吗?你能解决吗?
我希望我的应用程序在不同的平台上运行,并且应该能够通过Internet更新不同的客户端,每个客户端都有自己的数据库.所以我决定使用Mono和MySQL.如果有人知道任何更好的数据库用于此任务,这也可能是一个选项.我不想使用Java或任何其他编程语言,因为我在Windows上开发.net应用程序方面有一些经验.
谢谢你的帮助!
解决方法:
SecurityRulesAttribute类特定于.NET v4.0,请确保您的项目是为该运行时版本构建的.默认情况下,我认为MonoDevelop是为.NET v3.5构建的.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!