UWP - SQLite - An attempt was made to load a program with an incorrect format


I have taken over a UWP application that uses a SQLite database and runs perfectly locally on the same PC as WebService. I created the packages by using the store to run it on a Microsoft Surface (x64 Windows 10 Professional).

The application calls a SOAP WebService in ASP.Net on a PC - x64 Windows 10 Professional - (it is in development phase therefore not on a server) via the IP of the PC. The API creates a SQLite database from a SQL Server database to return it in another method.

Here's my problem:

When creating a connection to SQLite database (I get the connectionString with SqliteConnectionStringBuilder from an .db file that is on the same PC as WebService), I have an error that occurs :

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

So I searched on the different forums and tested the different solutions ( generate the UWP application in x86 / x64 / ARM / Any CPU, generate the API in x86 / x64 / Any CPU) but nothing worked. So I don't really know what to do. Do you have any ideas?

The code :

     /// <summary>
        /// Creates the SQLite database from the schema read from the SQL Server.
        /// </summary>
        /// <param name="sqlitePath">The path to the generated DB file.</param>
        /// <param name="schema">The schema of the SQL server database.</param>
        /// <param name="password">The password to use for encrypting the DB or null if non is needed.</param>
        private static void CreateSQLiteDatabase(string sqlitePath, DatabaseSchema schema, string password,bool createViews)

                    // Create the SQLite database file

                    // Connect to the newly created database
                    string sqliteConnString = CreateSQLiteConnectionString(sqlitePath, password);

                    //Here the exception
                    using (SQLiteConnection conn = new SQLiteConnection(sqliteConnString))


CreateSQLiteConnectionString method :

/// <summary>
/// Creates SQLite connection string from the specified DB file path.
/// </summary>
/// <param name="sqlitePath">The path to the SQLite database file.</param>
/// <returns>SQLite connection string</returns>
private static string CreateSQLiteConnectionString(string sqlitePath, string password)
    SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
    builder.DataSource = sqlitePath;
    if (password != null)
        builder.Password = password;
    builder.PageSize = 4096;
    builder.UseUTF16Encoding = false;
    string connstring = builder.ConnectionString;

    return connstring;

I don't know if dlls are missing, this is the first time I've used UWP and SQLite.

Thanks in advance for your answers.

asked on Stack Overflow Aug 7, 2018 by dchata

1 Answer


With the question suggestions by StackOverflow, I found my answer :

I had to allow 32-bit applications on my application pool in IIS. (I get a "An attempt was made to load a program with an incorrect format" error on a SQL Server replication project)

answered on Stack Overflow Aug 8, 2018 by dchata

User contributions licensed under CC BY-SA 3.0