(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
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(false, false))
.BuildSessionFactory();
//.Mappings(m =>
// m.FluentMappings
// .AddFromAssemblyOf
//.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.

Smart LuckyPosted Jul 31, 2013, 4:48 AM
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
Posted Jul 26, 2013, 3:57 PM