Ninject 看起来很棒,所以我想在我的项目中使用它。不幸的是,我仍在努力做最琐碎的绑定。[Inject] 属性编译得很好,但是编译器找不到“Bind”命令:
using System;
using Ninject.Core;
using Ninject.Core.Binding;
namespace NinjectTest
{
public interface IFoo
{
void DoSomething();
}
public class Foo : IFoo
{
public void DoSomething()
{
throw new NotImplementedException();
}
}
public class Bar
{
[Inject] private IFoo theFoo;
public Bar()
{
Bind<IFoo>().To<Foo>(); //Compiler Error: "The name 'Bind' does not exist in the current context"
}
}
}
这里可能出了什么问题?