Skip to content

ninject/Ninject.Extensions.Wcf

Repository files navigation

Ninject.Extensions.Wcf

Build status NuGet Version NuGet Downloads

This extension adds support for dependency injection for WCF services and behaviors.

There are three Ninject ServiceHostFactorys which could be used in IIS host and self host.

  • Ninject.Extensions.Wcf.NinjectServiceHostFactory is used for ordinary services
  • Ninject.Extensions.Wcf.NinjectWebServiceHostFactory is used for REST services
  • Ninject.Extensions.Wcf.NinjectDataServiceHostFactory is used for data services

There is a NinjectBehaviorExtensionElement which could resolve WCF behaviors with dependencies.

<system.serviceModel>
...
  <extensions>
    <behaviorExtensions>
      <add name="yourBehaviorName" 
           type="Ninject.Extensions.Wcf.BaseNinjectBehaviorExtensionElement+NinjectBehaviorExtensionElement`1[[YourAssembly.YourBehavior, YourAssembly]], Ninject.Extensions.Wcf" />
    </behaviorExtensions>
  </extensions>
...
</system.serviceModel>

You can find more details in wiki page.