Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject.Web.WebApi 3.2.4 GlobalConfiguration.Configure cannot be resolved

I updated the Nuget package Ninject.Web.WebApi from 3.2.3 to 3.2.4. After that update the GlobalConfiguration does not contain the function Configure anymore. That way the following code in the Global.asax.cs does not work anymore:

GlobalConfiguration.Configure(WebApiConfig.Register);

I tried the following:

WebApiConfig.Register(GlobalConfiguration.Configuration);

But that did not work.

Any ideas?

EDIT:

After I install the update via nuget, it removes the following two entries form the packages.config:

<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" />

<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" />

And in the csproj file it removes the reference to System.Web.Http.WebHost.

After I add them back, the project compiles, but the WebApi Controllers do not work, because Ninject does not inject the parameters. The error is:

An error occurred when trying to create a controller of type 'HomeController'. Make sure that the controller has a parameterless public constructor.

Has something fundamental changed in the latest update?

like image 418
Michael Avatar asked Jun 07 '26 23:06

Michael


1 Answers

3.2.4 introduced a breaking change, you can read about it in the release notes. You will need to install an additional nuget package now Ninject.Web.WebApi.WebHost.

like image 146
Cayne Avatar answered Jun 10 '26 15:06

Cayne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!