[英]Exception unhandled, connecting to MySql in c#?
你好可愛的堆棧的人,
我收到一條未處理的異常消息:
System.IO.FileNotFoundException: '無法加載文件或程序集'System.Security.Permissions,版本=4.0.3.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51'。 該系統找不到指定的文件。'
編碼:
private static string connectionString = @"Server=localhost; Port=100; Database=mmo_db; Uid=root; Pwd=;";
private static void StartDatabase() {
// MySQL Connection
try {
mysqlCon = new MySqlConnection(connectionString);
mysqlCon.Open();
Console.WriteLine("Connecting to MySQL databaase...");
}
catch (MySqlException e) {
Console.WriteLine("Error: {0}", e.ToString());
if (mysqlCon != null)
mysqlCon.Close();
Console.WriteLine("Server will now shutdown. Press any key to continue...");
Console.ReadLine();
Environment.Exit(0);
}
finally {
Console.WriteLine("MySQL successfully connected. (Version {0})", mysqlCon.ServerVersion);
while (true) {}
}
}
未處理的異常消息:*
耳朵周圍有點綠我不明白代碼有什么問題,非常感謝任何幫助!
提前致謝!
您似乎沒有在連接字符串中提供正確的憑據來訪問數據庫。
嘗試在連接字符串中提供密碼,因為您的密碼似乎為空?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.