Skip to content

Connection Database Using NHibernate getting Exception

Smart    Lucky

Smart Lucky

Asked Jul 22, 2013, 9:09 PM EDT2 answers
Share
LinkedInX
Hi dudes i am trying to connect database using NHibernate in this way but unfortunately getting exception, can nay one help me how can i solve this.
(using vs 2012)


 private static ISessionFactory SessionFactory
        {
            get
            {
                if (_sessionFactory == null)
                    InitilizeSessionFactory();

                return _sessionFactory;
            }
        }
        public static string localDb = @"Data Source=.;Initial Catalog=23;Integrated Security=True";
        private static void InitilizeSessionFactory()
        {
            _sessionFactory = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008
                              .ConnectionString(localDb)

                ).Mappings(c =>
                           c.FluentMappings
                                .AddFromAssemblyOf<Student>())
                    .ExposeConfiguration(cfg => new SchemaExport(cfg)
                        .Create(false, false))
                        .BuildSessionFactory();

                //.Mappings(m =>
                //          m.FluentMappings
                //              .AddFromAssemblyOf<Student>())
                //.ExposeConfiguration(cfg => new SchemaExport(cfg)
                //.Create(false, false))
                //.BuildSessionFactory();

         
       
///////////////Exception//////////////


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

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Do you have inner exception details?
    0
  • Smart    Lucky
    0
    Hi This is InnerExceptoin Detail
     
    Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
    Possible causes are:
    - The NHibernate.Bytecode provider assembly was not deployed.
    - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.

    Solution:
    Confirm that your deployment folder contains one of the following assemblies:
    NHibernate.ByteCode.LinFu.dll
    NHibernate.ByteCode.Castle.dll
    0