0

I previously had a working console application project that will read and write settings to a local SQLite database file.

Based on this project, I converted it to a windows service project by porting over the classes and use the ServiceBase class to create the the service. However, each time I run the service, I keep getting an SqliteException with the Message SQLite Error 1: 'no such table: Settings'.

Using DB Browser for SQLite, I do see the table present in the database file so I am not sure what is going on.

I have tried testing with my own account using Windows Service, I have tried giving Local System access to my build folder for testing.

I am not sure if this helps but I have also included part of the DbContext file:

public class CDIContext : DbContext
{
    public DbSet<Setting> Settings { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder options)
    {
        options.UseSqlite("Data Source=ApplicationData.db");
    }
}

public class Setting
{
    [Key]
    public Int32 Id { get; set; }
    [Required]
    public Int64 LastUpdateEpochUTC { get; set; }
}
amsga
  • 98
  • 12

1 Answers1

0

Found out that the Windows Service Working directory is located in either: C:\Windows\System32 or C:\Windows\SysWOW64 and not my application directory

What directory does a Windows Service run in?

As such, my database files were being searched in those directories instead of the application directory.

Will take @ErikEJ advice and change to a full path.

amsga
  • 98
  • 12