简体   繁体   中英

SQL.Data.SqlLite version with NHibernate 2.1

What version/implementation of the SQLLite can be used with NHibernate. I get an error:

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.

Let me say that dll is in the bin directory, I made sure. I am using System.Data.SQLite.DLL version 1.0.60.0.

Here is the hibernate.cfg.xml

    <property name="connection.driver_class">
        <!--NHibernate.Driver.SqlClientDriver-->
        NHibernate.Driver.SQLiteDriver
    </property>
     <property name="connection.connection_string">
        <!--    Server=.\SQLEXPRESS;User Id=epitka;Password=password;Database=dnn49;-->
        Data Source=nhibernate.db;Version=3
  </property>
  <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>

  <property name="query.substitutions">true=1;false=0</property>

  <property name="show_sql">true</property>

I am running this on Window XP box.

IDbCommand and IDbConnection are in the System.Data namespace, not in SQLite. Would you post your nhibernate configuration settings?

Here are the relevant settings

dialect = NHibernate.Dialect.SQLiteDialect, NHibernate
connection.driver_class = NHibernate.Driver.SQLite20Driver, NHibernate

SQLite20Driver is for System.Data.SQLite, while SQLiteDriver is for SQLite.NET. So SQLite20Driver is your answer.

I had the same problem on Windows 7 x64 , if that is the case; download the binary distribution of SQLite ( http://sqlite.phxsoftware.com/ ) and reference the x64 version.

Mistery solved:

If you get the configuration template from the NHibernate's lib\\NHibernate\\Configuration_Templates folder, they you have to get the dll for sqllite from this url http://sourceforge.net/projects/adodotnetsqlite/ which is SQLite and driver is NHibernate.Driver.SQLiteDriver. But as the web site says this project is deceased.

So you go and download new System.Data.SQLite.DLL from this url or from FluentNhibernate lib folder http://sourceforge.net/projects/sqlite-dotnet2/ and driver is NHibernate.Driver.SQLite20Driver

See that 20 in the driver name?

Anyway just though I might clarify the mystery.

我得到了这个,但它只是我没有在我的测试项目中的引用上设置CopyLocal = True。

I also encountered this error, it's really make me crazy. but I resovled it.And sharing with you,may it help you See this Link

Got this error trying Castle ActiveRecord with SQLite in VS2010. Solved it by following this instructions and changing the targeted framework from .NET 4 to .NET 3.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM