1

When I try installing Ninject.Web I get:

Unable to resolve dependencies. 'Ninject 3.3.4' is not compatible with 'Ninject.Web 3.2.1 constraint: Ninject (>= 3.2.0 && < 3.3.0)'

In this SO answer, it is said that we don't have to use Ninject.Web. But without it I can't inject dependencies for a regular WebForms page in the constructor.

So how should I inject dependency into a regular webforms page if I can't install Ninject.Web together with the latest Ninject package? And I don't want to downgrade Ninject module to a previous version.

bati06
  • 307
  • 2
  • 10
  • The error is pretty clear. Ninject.Web has a dependency on a specific range of versions of Ninject. If you want to continue using Ninject.Web 3.2.1, you must use a version of Ninject that falls within the range that it specifies. The solution is to simply install a compatible version of Ninject into your project. – mason Feb 01 '19 at 14:59
  • My question is referring to what should I do if I don't want to downgrade my Ninject package. – bati06 Feb 01 '19 at 22:06
  • Ninject.Web hasn't been updated since 2014. That's 5 years, an eternity in dev time. Are you really sure you want to be using something that hasn't been maintained properly? I wired up Simple Injector to ASP.NET 4.7.2's new constructor injection support, it was pretty easy. You might look into that. Is this an existing app, or a new one you're starting? If it's new, it's probably better to jump to ASP.NET Core and MVC where DI support is far better. – mason Feb 02 '19 at 01:34
  • I understand that Asp.Net Web Forms is a legacy technology, but it's a bit strange that it is not supported by current Ninject. – bati06 Feb 06 '19 at 15:20
  • Ninject and Web Forms can work together. You just have to use a specific version of Ninject. If you want newer versions, then perhaps you should open an issue with them, or contribute a PR. – mason Feb 06 '19 at 17:28

0 Answers0