biergarten
biergarten

Reputation: 53

Using Ninject.Extensions.Wcf for a web service hosted in ASP.NET MVC 2

i am using ninject in a wcf web service.This web service is hosted in a project created as a "ASP.NET MVC 2 Empty Web Application".

It is using the references for Ninject.dll v2 and Ninject.Extensions.Wcf.dll v1.

The markup for the service file is

<%@ ServiceHost 
Language="C#"
Debug="true"
Service="wcf_ninject.Service1"
CodeBehind="Service1.svc.cs"
Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>

The global.asax is inheriting from NinjectWcfApplication

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

with

public class WCFNinjectModule : NinjectModule
{
    public override void Load()
    {
        Bind<IRepository>().To<EFRepository>();
        // rest of bindings
    }
}

and the only constructor for the service is:

public Service1(IRepository repository)
{
    _repo = repository;
}

Most of the time works fine, but from time to time i get the error:

"Error activating Service1 More than one matching bindings are available"

But as said i am unable to find a reproduction path.

Upvotes: 2

Views: 459

Answers (1)

Remo Gloor
Remo Gloor

Reputation: 32725

I assume you are using an older version. I can remember there was a multithreading issue with implicit bindings in 2.1 or even 2.0. It should be fixed in 2.2 and 3.0.

Upvotes: 1

Related Questions