Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6680593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:29:33+00:00 2026-05-26T04:29:33+00:00

Can anybody point me in the right direction to get Ninject working with WCF

  • 0

Can anybody point me in the right direction to get Ninject working with WCF Web API Preview 5? I have it successfully up and running in my ASP.NET MVC 3 project and also in another internal WCF Service using the Ninject.Extensions.Wcf library. However I cannot get it to work when creating a new MVC 3 project and getting the WebApi.All library from NuGet.

I have looked at this stackoverflow post Setting up Ninject with the new WCF Web API but cannot get it working which I believe could be to do with some of the changes in the latest release.

I am also unsure which Ninject Libraries to reference beyond the main one. Do I use the Ninject.MVC3 , Ninject.Extensions.Wcf.

Any help on this would be much appreciated.

****UPDATE**

Code I am using which is from the answer in the question mentioned above. I have this in its own class file.

   public class NinjectResourceFactory : IResourceFactory
    {
        private readonly IKernel _kernel;

        public NinjectResourceFactory(IKernel kernel)
        {
            _kernel = kernel;
        }

        public object GetInstance(Type serviceType, InstanceContext instanceContext, HttpRequestMessage request)
        {
            return _kernel.Get(serviceType);
        }

        public void ReleaseInstance(InstanceContext instanceContext, object service)
        {
            // no op
        }
    }

This I have in my global.asax:

var configuration = HttpConfiguration.Create().SetResourceFactory(new NinjectResourceFactory());
RouteTable.Routes.MapServiceRoute<myResource>("resource", configuration);

The issue I am having is that the IResourceFactory interface is not recognised and that the HttpConfiguration.Create() no longer exists so I need to set the SetResourceFactory some other way which I have tried to do using the HttpConfiguration().CreateInstance method but no joy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:29:34+00:00Added an answer on May 26, 2026 at 4:29 am

    Following is my code with Ninject and WebApi,it works.
    Create a class inherites from WebApiConfiguration

    public class NinjectWebApiConfiguration : WebApiConfiguration {
        private IKernel kernel = new StandardKernel();
    
        public NinjectWebApiConfiguration() {
            AddBindings();
            CreateInstance = (serviceType, context, request) => kernel.Get(serviceType);
        }
    
        private void AddBindings() {
            kernel.Bind<IProductRepository>().To<MockProductRepository>();
        }
    
    }
    

    and use the NinjectWebApiConfiguration in RegisterRoutes

    public static void RegisterRoutes(RouteCollection routes) {
    
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        var config = new NinjectWebApiConfiguration() { 
            EnableTestClient = true
        };
    
        routes.MapServiceRoute<ContactsApi>("api/contacts", config);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody point me in the right direction to be able to encrypt a
can anybody point me in the right direction as to how I would go
I just wondered if anybody can point me in the right direction: I'm looking
We have a Logitech web cam that we want to get working with .NET.
Can anybody point me to a simple example about how to implement form based
Can anybody point me to a good beginner's guide for making Facebook apps?
can anybody tell me what's the point if any for a javascript function like
Can anybody give any working example of how to read/write Unicode text files using
Can anybody please tell me why the removeEventListener call is not working? this.addEventListener(Event.ENTER_FRAME, eventCall,
I'm trying to build this layout with views: http://screencast.com/t/3DFHcuwtfXV Can anybody point me in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.