MissingManifestResourceException在配置NHibernate与SQLite

本文关键字:SQLite NHibernate 配置 MissingManifestResourceException | 更新日期: 2023-09-27 18:06:07

我一直在尝试配置NHibernate与SQLite数据库,我似乎被卡住了一个异常,我不知道如何处理。

这是我的hibernate.cfg.xml文件:

<?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>

这是我的person。hbm.xml文件:

<?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>

当运行以下代码时,我得到一个MissingManifestResourceException(在最后一行)

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

我使用。net 4.0在Windows 7的终极64位。

非常感谢任何帮助。谢谢!

MissingManifestResourceException在配置NHibernate与SQLite

最新版本的。net SQLite发布为2个dll。

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

这两个dll需要出现在与EXE相同的文件夹中。互操作dll是特定于平台的,所以您必须手动(或构建后)复制x86或x64版本。

另一件要记住的事情是SQLite.Interop.dll本身依赖于MSVCR100.DLL (Visual c++ 2010 SP1可重新分发包的一部分)。你可以在这里下载:
  • 64位版本
  • 32位版本

请确保您从新的网站下载,该项目现在由SQLite团队支持:

SQLite.org的人已经接管了System.Data.SQLite项目。新的版本可以在新的网站System.Data.SQLite.org