I am trying to display data that is fetched from database, MySQL. However, this error is persistently showing when run and the emulator forcely close itself with a message of: System.Configuration.ConfigurationErrorsException: 'Configuration system failed to initialize'
Is there a way to fix this problem?
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();
}
CodePudding user response:
Use the MySqlConnector NuGet package. There are reports of the error you mention when using MySql.Data.
The System.Configuration stuff is mostly not available on Xamarin. This is a hint you may be using a version not made for Xamarin.