相关疑难解决方法(0)

Ninject的编译错误

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"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这可能会出错?

c# ninject

0
推荐指数
1
解决办法
581
查看次数

标签 统计

c# ×1

ninject ×1