我正在尝试与ServiceStack一起运行Sqllite内存数据库。
Visual Studio .net 4.6.1中的控制台应用程序
(如果我在LinqPad中运行相同的代码,它工作正常)
平台目标:x64
Install-Package ServiceStack.OrmLite.Sqlite64
static void Main(string[] args)
{
OrmLiteConfig.DialectProvider = SqliteDialect.Provider;
using (IDbConnection db = ":memory:".OpenDbConnection())
{
}
}
然后运行此应用程序,我收到此错误:
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>
答案 0 :(得分:2)
在所有版本的ServiceStack中,您需要为所有ServiceStack软件包引用相同版本。您的packages.json显示它引用了已弃用的ServiceStack.OrmLite.Sqlite64 NuGet包的旧v4.0.42。
OrmLite.Sqlite64 和 OrmLite.Sqlite32 已被弃用到 ServiceStack.OrmLite.Sqlite.Windows NuGet包中,其中包含32位和64位原生.dll。
PM> Install-Package ServiceStack.OrmLite.Sqlite.Windows
您还可以使用适用于Linux和Windows的 ServiceStack.OrmLite.Sqlite.Mono Sqlite NuGet包,并引用原生sqlite3.dll
。