I'm attempting to ninject ApiControllers in an Azure worker role. I've previously accomplished ninjection with the same controllers in an asp.net mvc 5 / web api 2 project in the same solution. Another non ninjected test controller in this WorkerRole project work and serve expected results.
While attempting to add the NuGet package Ninject.Web.WebApi.OwinHost (version 3.2.x) it looks like that package is ?erroneously? requiring a Ninject version ≥ 220.127.116.11 && < 18.104.22.168
Install-Package Ninject.Web.WebApi.OwinHost -ProjectName WorkerRole1 Install-Package Ninject.Web.WebApi.OwinHost -Pre -ProjectName WorkerRole1 Install-Package Ninject.Web.WebApi.OwinHost -Version 3.2.0 -ProjectName WorkerRole1 Install-Package Ninject.Web.WebApi.OwinHost -Version 3.2.1-unstable-002 -ProjectName WorkerRole1
I was able to successfully add Ninject.Web.WebApi.SelfHost, however I believe I need the owin flavor and SelfHost didn't appear to install NinjectWebCommon.cs or equivalent. I don't know where to wire up ninject to the owin self host in the worker role once I am successful at including the OwinHost. I'm assuming it will be scaffold-ed in.
Result of attempting to install Ninject.Web.WebApi.OwinHost
PM> Install-Package Ninject.Web.WebApi.OwinHost -Pre -ProjectName WorkerRole1 Attempting to resolve dependency 'Ninject.Web.WebApi (≥ 3.2.0-unstable)'. Attempting to resolve dependency 'Ninject (≥ 22.214.171.124 && < 126.96.36.199)'. Attempting to resolve dependency 'Ninject.Web.Common (≥ 188.8.131.52 && < 184.108.40.206)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi (≥ 5.0 && < 6.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 5.1.2 && < 5.2.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.1.2 && < 5.2.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.1.2)'. Attempting to resolve dependency 'Newtonsoft.Json (≥ 4.5.11)'. Attempting to resolve dependency 'Ninject.Web.Common.OwinHost (≥ 3.0 && < 4.0)'. Attempting to resolve dependency 'Ninject.Extensions.ContextPreservation (≥ 3.0 && < 4.0)'. Attempting to resolve dependency 'Ninject (≥ 220.127.116.11 && < 18.104.22.168)'. Install-Package : Updating 'Ninject 22.214.171.124' to 'Ninject 126.96.36.199' failed. Unable to find versions of 'Ninject.Web.WebApi, Ninject.Web.Common' that are compatible with 'Ninject 188.8.131.52'. At line:1 char:1 + Install-Package Ninject.Web.WebApi.OwinHost -Pre -ProjectName WorkerRole1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand PM>
Probably unrelated however in checking versions of installed package in the WorkerRole I note that a number of packages are IIS specific. Are these needed in an Azure WorkerRole Owin self host? And specifically for Microsoft.AspNet.WebApi.SelfHost I see the following notation yet I do have Microsoft.AspNet.WebApi.OwinSelfHost installed.
This is a legacy package for hosting ASP.NET Web API within your own process (outside of IIS). Please use the Microsoft.AspNet.WebApi.OwinSelfHost package for new projects.
Installed packages in WorkerRole
PM> Get-Package -ProjectName WorkerRole1 Id Version Description/Release Notes -- ------- ------------------------- EntityFramework 6.1.0 Entity Framework is Microsoft's recommended data access technology for new applications. Microsoft.AspNet.Identity.Core 2.0.0 Core interfaces for ASP.NET Identity. Microsoft.AspNet.Identity.E... 2.0.0 ASP.NET Identity providers that use Entity Framework. Microsoft.AspNet.WebApi 5.0.0 This package contains everything you need to host ASP.NET Web API on IIS. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of client... Microsoft.AspNet.WebApi.Client 5.1.2 This package adds support for formatting and content negotiation to System.Net.Http. It includes support for JSON, XML, and form URL encoded data. Microsoft.AspNet.WebApi.Core 5.1.2 This package contains the core runtime assemblies for ASP.NET Web API. This package is used by hosts of the ASP.NET Web API runtime. To host a Web API in IIS use the Microsoft.AspNe... Microsoft.AspNet.WebApi.Owin 5.1.2 This package allows you to host ASP.NET Web API within an OWIN server and provides access to additional OWIN features. Microsoft.AspNet.WebApi.Owi... 5.1.2 This package allows you to host ASP.NET Web API within your own process using the OWIN HttpListener server. ASP.NET Web API is a framework that makes it easy to build HTTP services ... Microsoft.AspNet.WebApi.Sel... 5.1.2 This is a legacy package for hosting ASP.NET Web API within your own process (outside of IIS). Please use the Microsoft.AspNet.WebApi.OwinSelfHost package for new projects. Microsoft.AspNet.WebApi.Web... 5.0.0 This package contains everything you need to host ASP.NET Web API on IIS. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of client... Microsoft.Data.Edm 5.6.1 Classes to represent, construct, parse, serialize and validate entity data models. Targets .NET 4.0, Silverlight 4.0, or .NET Portable Lib with support for .NET 4.0, SL 4.0, Win Pho... Microsoft.Data.OData 5.6.1 Classes to serialize, deserialize and validate OData payloads. Enables construction of OData producers and consumers. Targets .NET 4.0, Silverlight 4.0 or .NET Portable Lib with sup... Microsoft.Data.Services.Client 5.6.1 LINQ-enabled client API for issuing OData queries and consuming OData payloads. Supports OData v3. Targets .NET 4.0, Silverlight 4.0 or .NET Portable Lib with support for .NET 4.5, ... Microsoft.Owin 2.1.0 Provides a set of helper types and abstractions for simplifying the creation of OWIN components. Microsoft.Owin.Diagnostics 2.1.0 Provides middleware components to assist in developing OWIN-based applications. Microsoft.Owin.Host.HttpLis... 2.1.0 OWIN server built on the .NET Framework's HttpListener class. Currently the default server used for self-hosting. Microsoft.Owin.Hosting 2.1.0 Provides default infrastructure types for hosting and running OWIN-based applications. Microsoft.Owin.SelfHost 2.1.0 Includes components needed to host an OWIN-based application in a custom process. Microsoft.WindowsAzure.Conf... 2.0.3 Windows Azure Configuration Manager provides a unified API to load configuration settings regardless of where the application is hosted - whether on-premises or in a Cloud Service. Newtonsoft.Json 6.0.2 Json.NET is a popular high-performance JSON framework for .NET Ninject 184.108.40.206 Stop writing monolithic applications that make you feel like you have to move mountains to make the simplest of changes. Ninject helps you use the technique of dependency injection ... Ninject.Web.Common 220.127.116.11 Bootstrapper for web projects Ninject.Web.Common.Selfhost 18.104.22.168 Adds self hosting support to web common. Ninject.Web.WebApi 22.214.171.124 Extension for Ninject providing integration with ASP.NET MVC WebAPI 2 Ninject.Web.WebApi.Selfhost 126.96.36.199 Extension for Ninject providing integration with ASP.NET MVC WebAPI 2 Selfhost Owin 1.0 OWIN IAppBuilder startup interface System.Spatial 5.6.1 Contains classes and methods that facilitate geography and geometry spatial operations. Targets .NET 4.0, Silverlight 4.0 or .NET Portable Lib with support for .NET 4.0, SL 4.0, Win... WindowsAzure.Storage 188.8.131.52 This client library enables working with the Windows Azure storage services which include the blob service for storing binary and text data, the table service for storing structured... PM>