我正在努力Bootstrapper.csx
在 MacOSX 上的最新版本 ScriptCs (v0.14.0) 上编译以下文件:
using Autofac;
using Nancy.Bootstrappers.Autofac;
public class Bootstrapper : AutofacNancyBootstrapper
{
private readonly ILifetimeScope _lifetimeScope;
public Bootstrapper(ILifetimeScope lifetimeScope)
{
_lifetimeScope = lifetimeScope;
}
protected override ILifetimeScope GetApplicationContainer()
{
return _lifetimeScope;
}
}
它产生以下错误:
(15,39): error CS0508: `Bootstrapper.GetApplicationContainer()':
return type must be `Autofac.ILifetimeScope' to match overridden member
`Nancy.Bootstrappers.Autofac.AutofacNancyBootstrapper.GetApplicationContainer()'
/Users/tnt/Development/GitHub/scriptcs-gulp-nancyfx/scriptcs_packages
/Nancy.Bootstrappers.Autofac.1.1/lib/net40/Nancy.Bootstrappers.Autofac.dll
(Location of the symbol related to previous error)
我scriptcs_packages.config
的如下:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="3.5.2" targetFramework="net40" />
<package id="Nancy" version="1.1" targetFramework="net40" />
<package id="Nancy.Bootstrappers.Autofac" version="1.1" targetFramework="net40" />
<package id="Nancy.Hosting.Self" version="1.1" targetFramework="net40" />
</packages>
我基于此示例中的代码,所以我怀疑它应该可以工作:
如何使用 Autofac 为 Nancy 创建的子生命周期范围内的类型解析每个请求的实例依赖项
如果我做了一些非常明显的错误,我会提前道歉,但我只是看不到它......
更新:
遵循 Adam Ralph 的第一条评论中的流程大纲,但它仍然失败(在 MacOSX 上)如下: