当前位置:首页 > 数据库 > SQlite

NHibernate和SQLite异常

当我尝试使用GenerateSchema..i将映射表部署到数据库中时,出现异常:

NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLiteDriver. —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly SQLite.NET could not be found. Ensure that the assembly SQLite.NET is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly..

我试图用NHibernate.Driver.SQLiteDriver-> NHibernate.Driver.SQLite20Driver ..但是没有用..我添加了NHibernate,Sqlite..Linfu的所有引用.

有没有人想办法解决?

解决方法:

黑暗中的刺伤:

SQLite总是让我失望的一件事是它是一个混合程序集.它包含托管代码和本机代码,并以一种配置(通常为x86)为目标.如果您使用的是64位操作系统,并且使用的是x86版本,则可能是位数问题.不幸的是,这不会产生有用的错误消息.

尝试将项目设置为使用x86进行构建,看看是否有帮助.另外,请确保您具有正确版本的SQLite.某些版本(“仅托管”版本)开箱即用.我使用this version(解压缩,然后使用根目录中的“ System.Data.SQLite.DLL”文件).

I’ve run into these problems in the past and it took a bit of trial and error to get it working.


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!