asp.net mvc - IsessionFactory Issue -


i getting classic "object reference not set instance of object" error on line

httpcontext.items["isession"] = configure.getsessionfactory().opensession(); 

my configure.cs file follows

using system; using system.collections.generic; using system.linq; using system.text; using fluentnhibernate.cfg; using fluentnhibernate.cfg.db; using nhibernate;  namespace forsale.domain.nhibernate { public static class configure {     private static isessionfactory _sessionfactory;      public static void setup()     {         _sessionfactory = fluently.configure()             .database(mssqlconfiguration.mssql2008.connectionstring(cs => cs.fromconnectionstringwithkey("products")             ).showsql())             .mappings(m =>               m.fluentmappings.addfromassemblyof<product>().conventions.addfromassemblyof<product>())             .buildsessionfactory();     }      public static isessionfactory getsessionfactory()     {         return _sessionfactory;     } } } 

in webconfig have connection string

 <connectionstrings> <add name="products" connectionstring="data source=.\sqlexpress;attachdbfilename=|datadirectory|\products.mdf;integrated security=true;user instance=true" providername="system.data.sqlclient"/> 

with products.mdf in appcode folder build within vs2008

any ideas why might getting issue?

you change method getsessionfactory() following:

public static isessionfactory getsessionfactory() {     if (_sessionfactory == null)         setup();     return _sessionfactory; } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -