1

I've been trying to configure NHibernate with SQLite database, and i'm seemed to be stuck with an exception i do not know how to handle.

Here's my hibernate.cfg.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
    <property name="connection.connection_string">
      Data Source=mynewdatabase.dbf;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>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
 </session-factory>
</hibernate-configuration>

And here's my person.hbm.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               assembly="SQLiteObjects"
               namespace="SQLiteObjects.Domain">
  <class name="Person">
    <id name="Id">
      <generator class="guid" />
    </id>
    <property name="FirstName" />
    <property name="LastName" />
    <property name="Age" />
    <property name="Height" />
  </class>
</hibernate-mapping>

When running the following code, I get a MissingManifestResourceException (on the last line)

    var cfg = new Configuration();
    cfg.Configure();
    cfg.AddAssembly(typeof(Person).Assembly);
    new SchemaExport(cfg).Execute(false, true, false);
    PersonRepository pr = new PersonRepository();
    cfg.BuildSessionFactory();

I'm using .NET 4.0 on Windows 7 Ultimate 64-bit.

Would really appreciate any help. Thanks!

1
  • try getting into Fluent Nhibernate. It's much easier to configure, and there's no need for those messy xml configuration files... :) Commented Sep 2, 2011 at 12:16

1 Answer 1

1

Latest version of SQLite for .NET is distributed as 2 dlls.

  • System.Data.SQLite.dll
  • SQLite.Interop.dll

Both dlls need to be present in the same folder as your EXE. Interop dll is platform specific so you have to manually (or Post-build) copy x86 or x64 version.

Another thing to keep in mind is that SQLite.Interop.dll itslef depends on MSVCR100.DLL (part of Visual C++ 2010 SP1 Redistributable Package). You can get it here:

Also make sure that you download it from the new web site, the project is now supported by SQLite team:

The folks at SQLite.org have taken over ownership of the System.Data.SQLite project. New releases can be found at the new site, System.Data.SQLite.org

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.