我的CustomBootstrapper
样子如下
public class CustomBootstrapper : DefaultNancyBootstrapper
{
protected override NancyInternalConfiguration InternalConfiguration
{
get
{
//This will tell Nancy it won't have to look in the Nhibernate assemblies for implementations of our interfaces.
return NancyInternalConfiguration
.Default
.WithIgnoredAssembly(asm => asm.FullName.StartsWith("NHibernate", StringComparison.InvariantCulture))
.WithIgnoredAssembly(asm => asm.FullName.StartsWith("Fluent", StringComparison.InvariantCulture))
.WithIgnoredAssembly(asm => asm.FullName.StartsWith("Iesi", StringComparison.InvariantCulture));
}
}
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
base.ConfigureRequestContainer(container, context);
//container.Register((c, p) => SessionFactory.OpenSession());
container.Register(SessionFactory.OpenSession());
}
}
我有一个接受ISession
作为构造函数依赖项的存储库。当我运行我的应用程序时,我收到一条错误消息Unable to resolve type: NHibernate.ISession
我可以确认
- 我的引导程序被 Nanacy 捡到了
ISession
注册码执行.WithIgnoredAssembly(asm => asm.FullName.StartsWith("NHibernate", StringComparison.InvariantCulture))
我试过从属性中注释掉InternalConfiguration
- 两种注册组件的方式都出现错误(一种在我的代码中注释)
我已经查看了关于 SO 的其他类似问题,但到目前为止没有任何帮助。