6.10.0 SQLite connection string error

Hello

public void Configure(IServiceCollection services)
{
    var dbPath = "~/db.sqlite".MapServerPath();
    Console.WriteLine($"### {dbPath}");
        
    var dbConnectionFactory = new OrmLiteConnectionFactory(dbPath, SqliteDialect.Provider);
    using var db = dbConnectionFactory.Open();
    ....
    Upgrade(db);
    ....
}

net6.0

Console log gives correct full path to DB: ### C:\MyAppTEST\db.sqlite

With 6.9.0 code above works. With 6.10.0/6.10.1 following exception occurs:

Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter ‘path1’)
at System.IO.Path.Combine(String path1, String path2)
at System.Data.SQLite.SQLiteConnection…ctor(String connectionString, Boolean parseViaFramework)
at System.Data.SQLite.SQLiteConnection…ctor(String connectionString)
at ServiceStack.OrmLite.Sqlite.SqliteOrmLiteDialectProvider.CreateConnection(String connectionString) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite.Sqlite/SqliteOrmLiteDialectProvider.cs:line 12
at ServiceStack.OrmLite.Sqlite.SqliteOrmLiteDialectProviderBase.CreateConnection(String connectionString, Dictionary2 options) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite.Sqlite/SqliteOrmLiteDialectProviderBase.cs:line 206 at ServiceStack.OrmLite.OrmLiteConfig.ToDbConnection(String dbConnectionStringOrFilePath, IOrmLiteDialectProvider dialectProvider) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConfig.cs:line 141 at ServiceStack.OrmLite.OrmLiteConnection.get_DbConnection() in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConnection.cs:line 33 at ServiceStack.OrmLite.OrmLiteConnection.Open() in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConnection.cs:line 100 at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection() in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs:line 95 at ServiceStack.OrmLite.OrmLiteConnectionFactoryExtensions.Open(IDbConnectionFactory connectionFactory) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs:line 227 at MyApp.ConfigureDb.Configure(IServiceCollection services) in Z:\MyApp\MyApp\Configure.Db.cs:line 21 at ServiceStack.ModularStartup.<>c__DisplayClass30_0.<ConfigureServices>g__RunConfigure|0(Object instance) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/ModularStartup.cs:line 171 at System.Collections.Generic.List1.ForEach(Action1 action) at ServiceStack.ModularStartup.ConfigureServices(IServiceCollection services) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/ModularStartup.cs:line 194 at ServiceStack.ModularStartupActivator.ConfigureServices(IServiceCollection services) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/ModularStartup.cs:line 413 at System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at MyApp.Program.Main(String args) in Z:\MyApp\MyApp\Program.cs:line 18

Also, from debug everything works. From release version I’m getting exception. Building with

dotnet publish -c Release --self-contained -r win-x64

Tried clearning nuget caches and reinstalling packages again, no changes. Tried adding Servicestack.Ormlite.Sqlite.Data to project, also no luck. Haven’t found anything else in changelog for 6.10.0 to try.

Any tips?

Kind regards.

If it works in Debug then I’m assuming the issue is trying to run it as a self-contained executable. My only suggestion would be to switch to ServiceStack.OrmLite.Sqlite.Data NuGet package since it uses the Microsoft.Data.Sqlite maintained by Microsoft, but sounds like you’ve tried that already.

1 Like

Thank you for quick tip, it guided me to right direction.

It seems that in testing I haven’t replaced ServiceStack.OrmLite.Sqlite with ServiceStack.OrmLite.Sqlite.Data but added it. Removing package .Sqlite and adding .Sqlite.Data helped.
Thanks again.

1 Like