2

Does anybody out there know how to use Ninject with a WCF webHttp Service created using the WCF REST Service Template Extension? My project is using Ninject extensively and I want to implement a RESTful service, and as the new WCF Web API is not officially production ready I am left with the WCF REST Service Templates.

I have tried doing it the default way using the Ninject WCF extension from Nuget and having my Global.asax implement NinjectWcfApplication. I then load create the StandardKernal passing in my Ninject Service Module.

Unfortunatly I still end up with the error message due to nothing being injected.

The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.

I have also followed this article here without any luck.

Any help on this one greatly appreciated.

Cragly
  • 3,554
  • 9
  • 45
  • 59
  • The latest Ninject WCF Extension has an example of this. I also posted an example of how to do this using Ninject 2.2 here: https://github.com/chafey/Ninject-2.2-Wcf-Rest-Example – Chris Hafey Dec 21 '11 at 02:24

2 Answers2

2

See https://github.com/cbertolasio/ninject.extensions.wcf This will be integrated into the WCF extension master soon.

Remo Gloor
  • 32,665
  • 4
  • 68
  • 98
  • excellent thanks a lot. Would be useful to know when its merged with the WCF Extension trunk so can update my NuGet package. Thanks again. – Cragly Jun 20 '11 at 09:36
0

Take a look at this blog article from Jimmy Bogard. He talks about integrating StructureMap with WCF by hooking into WCF's InstanceProvider with a custom endpoint behavior, but I think it would work similarly for Ninject. I have not tried this with Ninject, so I'm just guessing here.

But hopefully this helps you out.

David Hoerster
  • 28,421
  • 8
  • 67
  • 102
  • Thanks but the article is similar in tone to the one mentioned in my question which looks at creating IServiceBehaviors to hook into the WCF pipeline. However can not get this to work with the REST Service Templates using WCF webHttp. – Cragly Jun 17 '11 at 16:42
  • I'm using WCF REST Starter Kit and followed Jimmy Bogard artcile that @David mentions but I don't use configuration from config file. – Tomasz Jaskuλa Jun 17 '11 at 18:13