MissingManifestResourceException on configuring NHibernate with SQLite
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!
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:
- 64 bit version
- 32 bit version
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
精彩评论