Search code examples
sqliteservicestack32-bitormlite-servicestack

OrmLite-named in memory database throwing exception


I am trying to use in memory database for unit test. following is set up for resolving apphost dependency of database

               OrmLiteConfig.DialectProvider = SqliteDialect.Provider;
                 var dbFactory =  new OrmLiteConnectionFactory();
                dbFactory.RegisterConnection("keyname",":memory:",SqliteDialect.Provider);
                container.Register<IDbConnectionFactory>(dbFactory); 

I am using sqlite(32 bit version) for 32bit machine. My project build target platform is "Any CPU". I am getting following error

An exception of type 'System.TypeInitializationException' occurred in ServiceStack.OrmLite.SqliteNET.dll but was not handled in user code

 Additional information: The type initializer for 'ServiceStack.OrmLite.Sqlite.SqliteOrmLiteDialectProvider' threw an exception.

am I missing some setting or anything? Thanks in advance.


Solution

  • Sounds like you're using the deprecated version of ServiceStack.OrmLite.Sqlite32 which was discontinued last year. Since you have a 32bit machine I'd recommend instead using:

    https://www.nuget.org/packages/ServiceStack.OrmLite.Sqlite.Mono/

    PM> Install-Package ServiceStack.OrmLite.Sqlite.Mono
    

    Which has the benefit of also working on Mono in both OSX/Linux.