StructureMap CacheBy InstanceScope.HttpSession not working

断了今生、忘了曾经 提交于 2019-12-01 13:23:17

问题


This is my StructureMap bootstrapping:

ObjectFactory.Initialize(factory =>
{
  //Business Conversation is per session
  factory.ForRequestedType<IConversation>().
    TheDefaultIsConcreteType<Conversation>().
      CacheBy(InstanceScope.HttpSession);

  //Session Factory is life time
  factory.ForRequestedType<INHibernateSessionManager>().
    TheDefaultIsConcreteType<NHibernateSessionManager>().
      CacheBy(InstanceScope.Singleton);
});

var conversation = ObjectFactory.GetInstance<IConversation>();

When I have my Conversation set to use .CacheBy(InstanceScope.HttpSession), I get Object reference not found, however If I don't use the CacheBy it works fine. This needs to go into the session, I'm not really sure why this isn't working.

Am I doing something wrong or does this appear to be a bug in StructureMap?


回答1:


To answer my own question, yes this is bug in StructureMap. The bug is fixed in the trunk or will be fixed in any binary release of 2.5.3 or later.



来源:https://stackoverflow.com/questions/497564/structuremap-cacheby-instancescope-httpsession-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!