Why 'timeout expired' exception thrown with StructureMap?
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-03-15T19:36:53Z
Indexed on
2010/03/15
19:39 UTC
Read the original article
Hit count: 605
I'm getting a "timeout expired" exception thrown from a relatively heavily trafficked ASP.NET MVC 2 site I developed using StructureMap and Fluent NHibernate.
I think that perhaps the connections aren't being disposed properly. What do you think may be causing this? Could it be my use of InstanceScope.Hybrid?
Here's my NHibernateRegistry class; thanks in advance for your help:
using MyProject.Core.Persistence.Impl;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.ByteCode.LinFu;
using NHibernate.Cfg;
using MyProject.Core.FluentMapping;
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;
namespace MyProject.Core.Persistence
{
public class NHibernateRegistry : Registry
{
public NHibernateRegistry()
{
FluentConfiguration cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(
x =>
x.FromConnectionStringWithKey(
"MyConnectionString"))
.ProxyFactoryFactory(typeof (ProxyFactoryFactory).AssemblyQualifiedName))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<EntryMap>());
Configuration configuration = cfg.BuildConfiguration();
ISessionFactory sessionFactory = cfg.BuildSessionFactory();
ForRequestedType<Configuration>().AsSingletons()
.TheDefault.IsThis(configuration);
ForRequestedType<ISessionFactory>().AsSingletons()
.TheDefault.IsThis(sessionFactory);
ForRequestedType<ISession>().CacheBy(InstanceScope.Hybrid)
.TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());
ForRequestedType<IUnitOfWork>().CacheBy(InstanceScope.Hybrid)
.TheDefaultIsConcreteType<UnitOfWork>();
ForRequestedType<IDatabaseBuilder>().TheDefaultIsConcreteType<DatabaseBuilder>();
}
}
}
© Stack Overflow or respective owner