Error “More than one matching bindings are available” when using Ninject.Web.Mvc 2.0 and ASP.NET MVC 1.0

I finally figured this issue out recently. Apparently, the NinjectHttpApplication.RegisterAllControllersIn() function doesn’t do all of the proper bindings needed. It binds your concrete controller implementations to IController requests. For example, if you have a controller class called SampleMvcController, which inherits from System.Web.Mvc.Controller. It would do the following named binding during application start: kernel.Bind<IController>().To(SampleMvcController).InTransientScope().Named(“SampleMvc”); But when … Read more

NinjectDependencyResolver fails binding ModelValidatorProvider

I was having all sorts of grief with the WebApi2 and Ninject initialization after upgrading the Ninject packages (even uninstalling and deleting the old ones). Specifically in your case I would remove these lines of code: // Use the container and our NinjectDependencyResolver as // application’s resolver var resolver = new NinjectDependencyResolver(container); GlobalConfiguration.Configuration.DependencyResolver = resolver; … Read more

Validation: How to inject A Model State wrapper with Ninject?

The solution given by that article mixes validation logic with the service logic. These are two concerns and they should be separated. When your application grows you will quickly find out that validation logic gets complicated and gets duplicated throughout the service layer. I, therefore, like to suggest a different approach. First of all, it … Read more

Guidelines For Dispose() and Ninject

The CLR documentation states that whoever creates a Disposable object is responsible for calling Dispose. In this case the object is created by Ninject. That means you should not call Dispose explicitly. Ninject disposes every Disposable object that has another scope other than InTransientScope as soon as the scope object to which the created object … Read more

Error Handling in asp.net mvc 3

For Global Error Handling All you have to do is change the customErrors mode=”On” in web.config page Error will be displayed through Error.cshtml resides in shared folder. Make sure that Error.cshtml Layout is not null. [It sould be something like: @{ Layout = “~/Views/Shared/_Layout.cshtml”; } Or remove Layout=null code block] A sample markup for Error.cshtml:- … Read more

With.Parameters.ConstructorArgument with ninject 2.0

[Fact] public void CtorArgTestResolveAtGet() { IKernel kernel = new StandardKernel(); kernel.Bind<IWarrior>().To<Samurai>(); var warrior = kernel .Get<IWarrior>( new ConstructorArgument( “weapon”, new Sword() ) ); Assert.IsType<Sword>( warrior.Weapon ); } [Fact] public void CtorArgTestResolveAtBind() { IKernel kernel = new StandardKernel(); kernel.Bind<IWarrior>().To<Samurai>() .WithConstructorArgument(“weapon”, new Sword() ); var warrior = kernel.Get<IWarrior>(); Assert.IsType<Sword>( warrior.Weapon ); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)