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 3322996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:14:58+00:00 2026-05-17T23:14:58+00:00

Any Ninject experts in the house? :) I’ve recently been trying to convert my

  • 0

Any Ninject experts in the house? 🙂
I’ve recently been trying to convert my WCF Service Application and Windows Forms Client Application from Castle Windsor dependency injection to Ninject.

All has gone fine on the Win Forms side, but I am encountering issues on the WCF side of things. I have learned so far I believe I need to WCF extensions available for Ninject in order to use DI with WCF which I have done and referenced but still experiencing an issue I believe when my service is attempted to be resolved:

System.InvalidOperationException: The type ‘WcfMemberService’, provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

The code I have which is what I thought to be correct to access just for instance my WcfMemberService is as follows:

ServiceModule.cs:

public class ServiceModule : NinjectModule
{
    private IKernel _parentContainer;
    public ServiceModule(IKernel container)
    {
    this._parentContainer = container;
    }

    public override void Load()
    {
    Bind<IDataContextProvider>().To<DataContextProvider>()
        .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
    Bind(typeof(IRepository<>)).To(typeof(Repository<>));
    Bind<IServiceLocator>().ToConstant(new NinjectServiceLocator(_parentContainer));
    Bind<IUserService>().To<UserService>();

    // ** WCF Services **
    Bind<Business.Common.Wcf.Services.Contracts.IMemberServiceContract>().To<Business.Common.Wcf.Services.MemberService>().InSingletonScope().Named("WcfMemberService");
    }
}

The assumption I made is when converting over from my working Castle Windsor configuration is that Named() should be the same entry which is featured in the declaration of your WCF .svc file. So I have done that as follows:

<%@ ServiceHost Language="C#" Service="WcfMemberService" Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>

Pretty simple, I have taken this approach from the TimeService example solution featured on the Ninject Wcf Extensions GitHub page here by the way.

Can anyone see what I have done wrong here and why “WcfMemberService” would not be resolving? It is bound to be “WcfMemberService” in the Kernel and referenced in the @ServiceHost declaration. I can’t see what else could be wrong. This is exactly the same as how I declare it in Castle Windsor, except for roughly different syntax, but both use Named() and both ref that name in the Service part of the .svc file.

*Update* I have discovered if I do not use the Named() approach, and simply set my service in @ ServiceHost declaration as Business.Common.Wcf.Services.MemberService, Business.Common.Wcf.Services it works. But I am still stumped as to why I can’t use Named services. Thanks.

By the way, my Ninject module is loaded via Global.asax.cs in this fashion:

public class Global : NinjectWcfApplication
{
    #region Overrides of NinjectWcfApplication

    /// <summary>
    /// Creates the kernel that will manage your application.
    /// </summary>
    /// <returns>The created kernel.</returns>
    protected override IKernel CreateKernel()
    {
        // config to reside in executing directory
        log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));
        var _container = new StandardKernel();
        _container.Load(new ServiceModule(_container));
        //_container.Load(new Log4netModule());
        ServiceLocator.SetLocatorProvider(() => _container.Get<IServiceLocator>());

        return _container;
    }

    #endregion
}
  • 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-17T23:14:58+00:00Added an answer on May 17, 2026 at 11:14 pm

    The .Named(string) syntax is used in conditional binding. For example, if you have

    Bind<IService1>().To<MyService>().Named("MyServiceImpl");
    Bind<IService1>().To<DefaultService();
    

    Then DefaultService will be injected as the default unless you have something like the following:

    class MyForm([Named("MyServiceImpl")] IService1 service){...}
    

    or

    kernel.Get<IService1>(metadata => metadata.Name == "MyServiceImpl");
    

    or

    kernel.Get<IService1>("MyServiceImpl");
    

    If you do not have a default binding for the type, and you only have the conditional named binding, then you will get an activation exception when you try to create an instance.

    -Ian

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .Net 4.0 WCF service that I'm trying to setup ninject for.
Okay, so recently I've been reading into ninject but I am having trouble understanding
I'm trying to replicate the following Ninject syntax in Unity, but not having any
Does anybody out there know how to use Ninject with a WCF webHttp Service
I'm using Ninject 2.2.1.4 and Ninject.Extensions.Wcf 2.2.0.4. My service is decorated with the following
I am trying to use Ninject 2.0 with Asp .Net 3.5 web application. Following
I am trying to profile an application which uses Ninject. I am using ANTS
I am currently using Ninject (2.2.1.4) and Ninject.Extensions.Wcf (2.2.0.4) with my WCF service. I
I'm using the Ninject.MVC3 in my application and it has been working great until
Anyone had any luck getting Ninject to work on MonoDroid? i've tried the 2.0

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.