I am trying to run the Sqllite inmemory database together with ServiceStack.
Console App in Visual Studio .net 4.6.1
(if I run the same code in LinqPad it is working fine)
Platform target: x64
Install-Package ServiceStack.OrmLite.Sqlite64
static void Main(string[] args)
{
OrmLiteConfig.DialectProvider = SqliteDialect.Provider;
using (IDbConnection db = ":memory:".OpenDbConnection())
{
}
}
Then running this app, I get this error:
An unhandled exception of type 'System.TypeLoadException' occurred in
ConsoleApplication1.exe
Additional information: Method 'CreateParam' in type
'ServiceStack.OrmLite.Sqlite.SqliteOrmLiteDialectProvider'
from assembly
'ServiceStack.OrmLite.SqliteNET,
Version=4.0.42.0,
Culture=neutral,
PublicKeyToken=null' does not have an implementation.
package.json:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Common" version="4.5.4" targetFramework="net461" />
<package id="ServiceStack.Interfaces" version="4.5.4" targetFramework="net461" />
<package id="ServiceStack.OrmLite" version="4.5.4" targetFramework="net461" />
<package id="ServiceStack.OrmLite.Sqlite64" version="4.0.42" targetFramework="net461" />
<package id="ServiceStack.Text" version="4.5.4" targetFramework="net461" />
</packages>
In all versions of ServiceStack you need to reference the same version for all ServiceStack packages. Your packages.json shows that it's referencing the older v4.0.42 of the deprecated ServiceStack.OrmLite.Sqlite64 NuGet package.
Both OrmLite.Sqlite64 and OrmLite.Sqlite32 have been deprecated into the ServiceStack.OrmLite.Sqlite.Windows NuGet package which contains 32bit and 64bit native .dlls.
PM> Install-Package ServiceStack.OrmLite.Sqlite.Windows
You can also use the ServiceStack.OrmLite.Sqlite.Mono Sqlite NuGet package which works on both Linux and Windows and references the native sqlite3.dll
.