views:

16

answers:

0

I'm writting simple application and i'm stuck in the defenition process it seems i'm lacking a reference or a dependency but after reading every blog/forum/starter kits i couldnot find the answer i hope you'll be able to help me

  1. I defined an employee class and mapping object with id, name and age

  2. created a database using sqlite and created the table (have in my project forlder an Employee.db file)

  3. wrote a hibernate.cfg.xml file:

`

<session-factory name="test">
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver </property>
    <property name="connection.connection_string">
        Data Source=C:\DAL\NH_Trial\SimpleMapping\Employee.db;Version=3
    </property>
    <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
    <property name="query.substitutions">true=1;false=0</property>
    <property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>

  1. my reference list includes:

    • Nhibernate
    • NHibernate.ByteCode.Castle
    • System.Data.SQLite.DLL
  2. my main function looks as follows:

    static void Main(string[] args)
    {
       Configuration configuration = new Configuration();
       configuration.Configure();
       configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly());
    
    
       ISessionFactory factory = configuration.BuildSessionFactory();
    }
    

the last line cause the exception

Could not create the driver from NHibernate.Driver.SQLiteDriver

I implemented the following suggestions with no help

  1. i tried replacing NHibernate.Driver.SQLiteDriver with NHibernate.Driver.SQLite20Driver
  2. i added the following to the app.config:

    <system.data>
        <DbProviderFactories>
            <remove invariant="System.Data.SQLite"/>
            <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
        </DbProviderFactories>
    

  3. my application build properties are set to x86

  4. i'm working with .net 4 so i tried the System.Data.SqlServerCe.dll & System.Data.SqlServerCe.Entities.dll that come with the Microsoft SQL Server Compact Edition\v3.5 (that msdn said it is good for .net 4 as well)
  5. i tried using NHibernate.ByteCode.LinFu instead of castle

your help will be greatly appriciated thanks