mercredi 1 juillet 2015

SQLiteException: CannotOpen file

Sometimes a user report this error:

[Type]:[SQLiteException]
[Message]:[Could not open database file: AppSettings.db (CannotOpen)]
[StackTrace]:[   at Community.SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
                 at Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsPhone.MvxWindowsPhoneSQLiteConnectionFactory.CreateSQLiteConnection(String databasePath, Boolean storeDateTimeAsTicks)
                 at Cirrious.MvvmCross.Community.Plugins.Sqlite.MvxBaseSQLiteConnectionFactory.CreateFileDb(SQLiteConnectionOptions options)
                 at Cirrious.MvvmCross.Community.Plugins.Sqlite.MvxBaseSQLiteConnectionFactory.CreateEx(SQLiteConnectionOptions options)
                 at Cirrious.MvvmCross.Community.Plugins.Sqlite.MvxBaseSQLiteConnectionFactory.CreateEx(String address, SQLiteConnectionOptions options)
                 at Cirrious.MvvmCross.Community.Plugins.Sqlite.MvxBaseSQLiteConnectionFactory.Create(String address)
                 at Timokids.Core.Services.AppSettingsService..ctor(ISQLiteConnectionFactory factory)]

My problem is, this error don't show always so I cannot debug it.

In most of the times the code run with no errors.

The error occurs when I call factory.Create().

Here is my code:

public class AppSettingsService : IAppSettingsService
{
    private readonly ISQLiteConnection _connection;

    public AppSettingsService(ISQLiteConnectionFactory factory)
    {
        _connection = factory.Create("AppSettings.db");
    }
}

Is there anything I can do for solve this?

Aucun commentaire:

Enregistrer un commentaire