{"id":5016,"date":"2014-03-30T17:57:26","date_gmt":"2014-03-30T17:57:26","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-ninject-web-mvc-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:57:26","modified_gmt":"2014-03-30T17:57:26","slug":"problem-about-ninject-web-mvc-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-ninject-web-mvc-collection-of-common-programming-errors\/","title":{"rendered":"problem about ninject.web.mvc-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/47f619dbd57ad1235269740318acbd12?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLiviu M.<br \/>\nc# asp.net-mvc-3 dependency-injection ninject ninject.web.mvc<br \/>\nI have a MCV3 app that uses Ninject as a DI container.I have one object that has 2 constructors (each with 1 parameter)public MyObject(IDependencyOne dep){} public MyObject(IDependencyTwo dep){}How can I make Ninject choose one of the two constructors based on some boolean value read from web.config file at runtime?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/00ecfd7a934c9c63c50b0a8c893ab00e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzirus<br \/>\nc# asp.net-mvc ninject.web.mvc<br \/>\nthis is my first question to SO so i&#8217;ll try not to disgrace myself.What i&#8217;m doing right now is injecting two dependency objects to a MVC3 Controller&#8217;s constructor. But for the sake of the application logic, i need to change those objects with new ones sometime in the (runtime) future. Apperently the obvious case would be to get MVC to create a new controller with the new objects injected. All well, but how do i make MVC produce new controllers?Here is the controller (if it is relevant, or just f<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc2525585a123ab0169554cae01e47b5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDave<br \/>\nninject ninject.web.mvc<br \/>\nI&#8217;m testing Ninject, but following the how-to, i find it impossible to make it work. The information on the web is so messy even contradictory. I&#8217;m developping a website in MVC 4 on visual studio 2012 and i did install Ninject using Nuget.So I get an error : &#8220;No parameterless constructor defined for this object.&#8221;. As soon as I enter my controller.I did the necessary steps :Nuget installation in NinjectWebCommon.cs, I did register my Interface in the RegisterServices method. In my homecontroller<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/16d172d075cff6acf012a030dda2d0c0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlthomaz<br \/>\nasp.net-mvc-3 mono ninject monodevelop ninject.web.mvc<br \/>\nI have a working Visual Studio project that I want to run o Mac with Mono and MonoDevelop. The project is an ASP.NET MVC 3 application with Ninject MVC that basically inject on controller some interface implementations. After add all ASP.NET MVC dlls and Ninject dependencies to the project, it compiles successfully. But when I go to run it, I have the error:Default constructor not found for type WebActivatorTest.Controllers.HomeController.My controller has the following code:public class HomeCo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3bf2f8634a11f7e0336690d6d0f47a5a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndove<br \/>\nmono asp.net-mvc-4 ninject ninject.web.mvc<br \/>\nI am using VS2012 RC and created a MVC4 app in .NET 4.0 mode. I use Ninject + Ninject.MVC3 as a DI container. It works on my development machine on Windows and on another machine with .NET 4.0 installed, but when I deploy it on a Linux server with Mono 3.0.2, XSP and fastcgi + lighttpd I just get a Ninject related error message:System.InvalidOperationException Sequence contains no matching elementat System.Linq.Enumerable.Single[DataAnnotationsModelValidatorProvider] (IEnumerable`1 source, Syste<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Liviu M. c# asp.net-mvc-3 dependency-injection ninject ninject.web.mvc I have a MCV3 app that uses Ninject as a DI container.I have one object that has 2 constructors (each with 1 parameter)public MyObject(IDependencyOne dep){} public MyObject(IDependencyTwo dep){}How can I make Ninject choose one of the two constructors based on some boolean value read from web.config file at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5016","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5016"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5016\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}