将Ninject/Ninject WCF扩展升级到最新版本3.0.0.5 [英] Upgrading Ninject/Ninject WCF Extensions to the latest version 3.0.0.5

查看:88
本文介绍了将Ninject/Ninject WCF扩展升级到最新版本3.0.0.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在WCF服务中使用Ninject(2.2.1.4)和Ninject.Extensions.Wcf(2.2.0.4).我想升级到Ninject(3.0.0.15)和Ninject.Extensions.Wcf(3.0.0.5),看起来我不能再使用当前的方法了.谁能给我指出一些示例或帖子,以获取有关如何在WCF项目中使用最新版本的Ninject的信息.

I am currently using Ninject (2.2.1.4) and Ninject.Extensions.Wcf (2.2.0.4) with my WCF service. I would like to upgrade to Ninject (3.0.0.15) and Ninject.Extensions.Wcf (3.0.0.5) and it doesn't look like I can use my current approach anymore. Can anyone point me to some samples or posts on how to get the latest version of Ninject working with a WCF project.

我目前的做法:

我写了一个模块:

public class NinjectDependencyResolver : NinjectModule
{
    public override void Load()
    {
        // Declare bindings
    }
}

我将Factory属性添加到了我的.svc文件中

I added the Factory Attribute to my .svc file

Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory"

我在WCF项目中添加了Global.asax

I added a Global.asax to the WCF project

public class Global : NinjectWcfApplication
{
    protected override IKernel CreateKernel()
    {
        return new StandardKernel(new NinjectDependencyResolver());
    }
}

现在,我可以在服务中修改默认构造函数并使用构造函数注入.

Now I can modify the default constructor in my service and use constructor injection.

任何有关如何升级的指示都将受到赞赏.

Any pointers on how I could upgrade are appreciated.

谢谢

推荐答案

添加Ninject.Web.Common并从NinjectHttpApplication派生,或使用NuGet包随附的App_Start文件.

Add Ninject.Web.Common and derive from NinjectHttpApplication or use the App_Start file that comes with the NuGet package.

这篇关于将Ninject/Ninject WCF扩展升级到最新版本3.0.0.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆