本文介绍了Ninject InRequestScope失踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关于ninject的最新版本(2.2.1.4)几个问题。
试图绑定LINQ2SQL 的DataContext
来具体实施 InRequestScope
(在一个类库项目)
绑定< DataContext的方式>()为<&MoneywatchDataContext GT;()
但无法找到 InRequestScope
法
弄成这样,
绑定<&DataContext的GT;()为<。MoneywatchDataContext方式>()InScope(CTX => HttpContext.Current)
只是想看看:
- 如果这样的行为完全像
InRequestScope
方法。 - ,它会出示担保,当我的
HTTContext.Current
是GC'ed底层DataCotext
将被布置成好。
解决方案
最有可能您引用Ninject一个没有网络版本。与普通版本来替换它,你将有InRequestScope扩展方法。
Have a couple of questions regarding the latest version (2.2.1.4) of ninject.
Was trying to Bind a Linq2sql DataContext
to a concrete implementation InRequestScope
(in a class library project)
Bind<DataContext>().To<MoneywatchDataContext>()
but could not find InRequestScope
method
ended up doing this,
Bind<DataContext>().To<MoneywatchDataContext>().InScope(ctx => HttpContext.Current)
Just wanted to find out if:
- If this will behave exactly like the
InRequestScope
Method. - That it will gurantee that when my
HTTContext.Current
is GC'ed the underlyingDataCotext
will be disposed as well.
解决方案
Most likely you reference a no web version of Ninject. Replace it with the normal version and you will have the InRequestScope extension method.
这篇关于Ninject InRequestScope失踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!