I am using asp.net mvc 3. I am using ninject 2.2.1.0
protected void Application_Start()
{
// Hook our DI stuff when application starts
SetupDependencyInjection();
}
public void SetupDependencyInjection()
{
// Tell ASP.NET MVC 3 to use our Ninject DI Container
DependencyResolver.SetResolver(new NinjectDependencyResolver(CreateKernel()));
}
protected IKernel CreateKernel()
{
var modules = new INinjectModule[]
{
new NhibernateModule(),
new ServiceModule(),
new RepoModule()
};
return new StandardKernel(modules);
}
The above is how I setup and I never had a problem with any of it until I changed my jquery ui tabs to ajax.
Now I have the page load then the first tab gets called and does an ajax request. Some times I get the following error message other times I don't. I am not sure why I am getting it.
Error activating _Page_Areas_Site_Views_Site_pDataTable_cshtml
More than one matching bindings are available.
Activation path:
1) Request for _Page_Areas_Site_Views_Site_pDataTable_cshtml
Suggestions:
1) Ensure that you have defined a binding for _Page_Areas_Site_Views_Site_pDataTable_cshtml only once.
I never told ninject to do binding(I only do my repos and service layers) so it must be doing it on it's own.
This may not serve as an actual answer, but I'll go for it anyway. I ran into the same problem, using Mvc 2 and Ninject 2.0.
I was working on a PhotoController that simply spat back images to the page. It would be hit thirty or so times per page request. I was using Ninject for dependencies with all of my controllers, and ran into problems with that specific controller.
Sometimes, Ninject would throw the exact same ActivationException you are encountering. The only way to make the error go away would be to restart the app pool.
After hours and hours of fiddling around trying to determine the cause, the only conclusion I came to was that Ninject must have a problem injecting dependencies in cases where a very large number of requests for the same instance occur. That was the only difference between the PhotoController and any other one in the project.
I solved the problem by switching to using a generic handler, and shortly after that, pre-determined blob storage urls.
Sorry I can't be of more help, but I posted a question about my experience on stack and never got a resolution to it.