Ambiguous Call When Upgrading to Ninject.Web.WebApi.OwinSelfHost

I have been given a task to upgrade a multi-project NuGet packages and it is an absolute mess. This project is an ASP.NET project targeting .NET Framework 4.6.1.

One of the packages that have been marked as deprecated is Ninject.Web.WebApi.OwinHost, it has been replaced with Ninject.Web.WebApi.OwinSelfHost. I uninstalled the former and installed the latter but I get a compile error on where it calls UseNinjectMiddleware:

// var assemblyName = "-redacted-"
// var config = new HttpConfiguration();
var ninjectKernel = NinjectCommon.CreateKernel(assemblyName);
app.UseNinjectMiddleware(() => ninjectKernel);
app.UseNinjectWebApi(config);

The error I am getting is:

The call is ambiguous between the following methods or properties: ‘Ninject.Web.Common.OwinHost.OwinAppBuilderExtensions.UseNinjectMiddleware(Owin.IAppBuilder, System.Func<Ninject.IKernel>)’ and ‘Owin.OwinAppBuilderExtensions.UseNinjectMiddleware(Owin.IAppBuilder, System.Func<Ninject.IKernel>)’

I did not setup this part of the application so I’m sort of at a loss as to how to resolve this. What makes this difficult is that the Ninject wiki (here) fails to load for me and I cannot find anything in my search engine searches.

Has this method changed between Ninject.Web.WebApi.OwinHost and Ninject.Web.WebApi.OwinSelfHost?

Leave a Comment