views:

36

answers:

1

I'm having problems with getting nhibernate to play nice with sqlite:

My NHibernate configuration:

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

I'm running on Windows 7 64 bit. I've tried copying both the x86 and the 64bit version of the system.data.sqlite.dll to the output dir as well as referencing them and setting them to copy local but to no avail. The VS solution has been set to compile to any/x86/64bit, but I'm still getting the exception:

"{"The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite 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."}"

What am I missing?

+2  A: 

I hit this one back in April and finally got it working - what a PITA! Try changing your config to support mixed loading AND add a runtime redirect like below.

I would have though there would be a SQLite release that fixes this by now but I guess not. Please let me know if you find out otherwise though.

Cheers,
Berryl

<!-- 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>
Berryl
You saved my day! And I agree that it should at least be in bold letters - 4.0 has been out for a while now...
Goblin