getting FluentConfigurationException in the "Getting started" project

Djiss's Avatar

Djiss

04 Sep, 2010 04:36 PM via web

In the function CreateSessionFactory, I'm getting FluentConfigurationException. I just started to try Fluent NHibernate and NHibernate to see if we could use it for our projects at work. I have no clue what this exception mean, so if anyone can explain me what I missed... Thank you.

Here's the code causing the exception :

private static ISessionFactory CreateSessionFactory()
{
  return Fluently.Configure()
    .Database(SQLiteConfiguration.Standard
        .UsingFile(DbFile))
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
    .ExposeConfiguration(BuildSchema)
    .BuildSessionFactory();
}

private static void BuildSchema(Configuration config)
{
  if (File.Exists(DbFile))
    File.Delete(DbFile);

  new SchemaExport(config)
    .Create(false, true);
}

And here is the exception.
FluentNHibernate.Cfg.FluentConfigurationException was unhandled
Message=An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

Source=FluentNHibernate StackTrace:

   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 98
   at Test1.Program.CreateSessionFactory() in E:\Projects\Test\Fluent NHibernate\Test1\Test1\Program.cs:line 110
   at Test1.Program.Main(String[] args) in E:\Projects\Test\Fluent NHibernate\Test1\Test1\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

InnerException: FluentNHibernate.Cfg.FluentConfigurationException

   Message=An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.


   Source=FluentNHibernate
   StackTrace:
        at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 119
        at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93
   InnerException: NHibernate.HibernateException
        Message=Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
        Source=NHibernate
        StackTrace:
             at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
             at NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings)
             at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings)
             at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop)
             at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, Boolean export, Boolean justDrop)
             at NHibernate.Tool.hbm2ddl.SchemaExport.Create(Boolean script, Boolean export)
             at Test1.Program.BuildSchema(Configuration config) in E:\Projects\Test\Fluent NHibernate\Test1\Test1\Program.cs:line 123
             at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 113
        InnerException: System.Reflection.TargetInvocationException
             Message=Exception has been thrown by the target of an invocation.
             Source=mscorlib
             StackTrace:
                  at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
                  at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
                  at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
                  at System.Activator.CreateInstance(Type type, Boolean nonPublic)
                  at System.Activator.CreateInstance(Type type)
                  at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
                  at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
             InnerException: NHibernate.HibernateException
                  Message=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 <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
                  Source=NHibernate
                  StackTrace:
                       at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
                       at NHibernate.Driver.SQLite20Driver..ctor()
                  InnerException:
  1. 2 Posted by Djiss on 04 Sep, 2010 05:09 PM

    Djiss's Avatar

    I forgot to specify thats I'm using VS2010, and the Fluent NHibernate version 1.1.0.692.

    I copied the content of the zip file in a .._SharedLibs\ folder then added the reference to FluentNHibernate.dll and the NHibernate.dll from the same folder.

    Everything compile fine, but the exception come as soon as I use the function CreateSessionFactory.

  2. 3 Posted by Djiss on 05 Sep, 2010 03:57 PM

    Djiss's Avatar

    I found the solution of my problem there, I just switched from SQLite to SQL Server : http://support.fluentnhibernate.org/discussions/help/298-compiling-...

    Which got me into another exception saying "NHibernate.ByteCode.Castle" or "NHibernate.ByteCode.LinFU" were missing.

    I manually added a reference to "NHibernate.ByteCode.Castle" in my project and now it's working.

  3. Djiss closed this discussion on 05 Sep, 2010 03:57 PM.

  4. James Gregory re-opened this discussion on 06 Sep, 2010 11:14 PM

  5. Support Staff 4 Posted by James Gregory on 06 Sep, 2010 11:14 PM

    James Gregory's Avatar

    Look at the InnerException. It's saying it can't find the SQLite driver; there have been several people saying they've had issues with SQLite and 64bit, are you on a 64bit machine?

    On 4 Sep 2010, at 17:38, "Djiss" <***@tenderapp.com> wrote:

    > Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.

  6. 5 Posted by Djiss on 09 Sep, 2010 01:18 PM

    Djiss's Avatar

    Yes I'm running on Win 7 x64.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What comes next? 'Monday Tuesday Wednesday ?????'