【问题标题】:NHibernate and SQLite woesNHibernate 和 SQLite 的困境
【发布时间】:2010-07-04 14:28:51
【问题描述】:

我在让 nhibernate 与 sqlite 一起玩时遇到问题:

我的 NHibernate 配置:

<NHibernate>
  <hibernate xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.connection_string">Data Source=test.db;New=True;</property>
      <property name="show_sql">false</property>
      <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
      <property name="use_outer_join">true</property>
      <property name="show_sql">false</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <mapping assembly="SimpleGallery" />
    </session-factory>
  </hibernate>
</NHibernate>

我在 Windows 7 64 位上运行。我尝试将 x86 和 64 位版本的 system.data.sqlite.dll 复制到输出目录以及引用它们并将它们设置为复制本地但无济于事。 VS 解决方案已设置为编译为 any/x86/64bit,但我仍然收到异常:

"{"在程序集 System.Data.SQLite 中找不到 IDbCommand 和 IDbConnection 实现。确保程序集 System.Data.SQLite 位于应用程序目录或全局程序集缓存中。如果程序集在 GAC 中,请使用应用程序配置文件中的元素来指定程序集的全名。"}"

我错过了什么?

【问题讨论】:

  • 不知道有没有用,不过你可以试试下载锐架构项目,里面配置了sql lite。

标签: nhibernate sqlite


【解决方案1】:

我在四月份打了这个,终于让它工作了 - 多么好的 PITA!尝试更改您的配置以支持混合加载并添加运行时重定向,如下所示。

虽然现在会有一个 SQLite 版本可以解决这个问题,但我想不会。如果您发现其他情况,请告诉我。

干杯,
浆果

<!-- SQLite requires this mixed mode load setting-->
<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  <requiredRuntime version="v4.0.20506"/>
</startup>

  <runtime>
   ....

  <!-- SQLite is built with older System.Data so we need this redirect -->
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/>
      <bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>

 ....
</runtime>

【讨论】:

  • 你拯救了我的一天!而且我同意它至少应该是粗体 - 4.0 已经发布了一段时间......
猜你喜欢
  • 2012-01-08
  • 1970-01-01
  • 1970-01-01
  • 2012-02-02
  • 1970-01-01
  • 2010-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多