Ninject DI causing deployment issues

asp.net-mvc, asp.net-mvc-4, deployment, ninject

Solution

I think you are building against .NET 4.5 and deploy on .NET 4.0 or you deploy Ninject for .NET 4.5 on .NET 4.0

Problem

I'm attempting to deploy a website that uses Ninject for DI which works well locally on my development machine (don't they all!). When deployed to my host (using the visual studio ftp publish option) I get the following error: ``` Method not found: 'System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)'. ``` and ``` [InvalidOperationException: An error occurred when trying to create a controller of type 'Website.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.] ``` Looking at the stack trace it appears NinjectDependencyResolver.GetService(Type serviceType) is the method that is failing. As I say, its working fine locally so don't really know where or how to being tackling this one. Googleing hasn't brought up anything useful. I'm using Ninject 3.0.1.10 if thats relevant. Edit: I've since added paramterless constructors to the homecontroller, but it has made no difference and the same error exists....

Original source