3
votes

I have an ASP.NET MVC 3 application. It runs successfully on my local machine, using IIS Express under Visual Studio 2012 RC.

But It doesn't seem to run on my server/host. I get the following error:

Error activating HomeController using implicit self-binding of HomeController No constructor was available to create an instance of the implementation type.

Activation path:

  1. Request for HomeController

Suggestions:

  1. Ensure that the implementation type has a public constructor.

  2. If you have implemented the Singleton pattern, use a binding with InSingletonScope() instead.

I have searched all over web, couldn't find a solution. It looks its an error because I don't have a constructor defined or have private constructor in my HomeController, but this is not the case.

I have NInject.dll in bin folder..

Can't figure out...

3
Is the controller public and non-abstract? Can you show the constructors? Most of the time the exception is exactly right... - Ruben Bartelink
There is no constructor defined for HomeController class. - Brij
... is the class public? Is there anything else interesting about the class? (there obviously is because most people are not having issues...) You're going to have to share more, or we're going to have to get very good at telepathy... - Ruben Bartelink
It really was a NInject.dll issue. I was using .NET 4.5 earlier and the web host had .NET 4.5. So I switched my application to .NET 4.0. I later picked up a NInject.dll from an application which was already running and replaced it current application's dll and it worked. Thank for your support - Brij

3 Answers

2
votes

I had trouble with this same issue with NInject and didn't read the whole message.

MAKE SURE YOUR CONSTRUCTOR IS PUBLIC

mine was protected. Hope that saves someone else time :)

0
votes

It really was a NInject.dll issue. I was using .NET 4.5 earlier and the web host had .NET 4.5. So I switched my application to .NET 4.0. I later picked up a NInject.dll from an application which was already running and replaced it current application's dll and it worked.

0
votes

I had the exact same issue and fixed it the same way.

For informational purposes, be aware that when I was comparing the ninject.dll on various servers (one of our servers worked with identical code) all of the .dll files were identical in version and size.

A colleague advised me to download a tool called Hashtab which confirmed that the dll's were actually different.

On all our servers, the sites were setup to run under .NET4.0 however on the server that worked, .NET4.5 was installed...the app pool the site ran under was .NET4 but obviously having .NET4.5 installed added some files.

If in doubt, remove the .dll, ensure your project is configured to build under the correct version of .NET framework and then add the dll via NuGet.