我正在嘗試顯示從資料庫 MySQL 獲取的資料。但是,此錯誤在運行時會持續顯示,并且模擬器會強制關閉自身并顯示以下訊息:System.Configuration.ConfigurationErrorsException: 'Configuration system failed to initialize'
有沒有辦法解決這個問題?
public IList<user> users { get; set; }
public TimeMonitoring()
{
InitializeComponent();
}
public class user
{
public string user_name { get; set; }
public string email { get; set; }
}
protected override void OnAppearing()
{
base.OnAppearing();
var koneksi = new MySqlConnection(Properties.Resources.db_con);
koneksi.Open(); // It is directing to this error
var cmd = new MySqlCommand("select * from users", koneksi); // It is directing to this error
var rd = cmd.ExecuteReader();
users = new List<user>();
while(rd.Read())
{
users.Add(new user
{
user_name = rd.GetString("user_name"),
email = rd.GetString("email"),
}
);
}
rd.Close();
listview_users.ItemsSource = users;
koneksi.Close();
}
uj5u.com熱心網友回復:
使用MySqlConnector NuGet 包。有你在使用 MySql.Data 時提到的錯誤的報告。
System.Configuration 的東西在 Xamarin 上大多不可用。這是一個提示,您可能正在使用不是為 Xamarin 制作的版本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/442265.html
標籤:C# 安卓 xamarin xamarin.forms
