I have a very simple web Api v2.2 hosted in OWIN
public class StartUp { public void Configuration(IAppBuilder appBuilder, IConfigReader configReader) { var container = new Container(); container.Register<IConfigReader, ConfigReader>(); var config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); appBuilder.UseWebApi(config); } }
When I then use on my Main() as:
WebApp.Start(baseAddress, appBuilder => new StartUp().Configuration(appBuilder, new ConfigReader()));
However, when I try to execute the last line of appBuilder.UseWebApi(config); I get the following exception:
The first random exception of type "SimpleInjector.ActivationException" occurred in SimpleInjector.dll
Additional Information: This type of IHostBufferPolicySelector is not a specific type. Please use one of the other overloads to register this type.
Full stack:
SimpleInjector.ActivationException occurred _HResult = -2146233088
_message = This type of IHostBufferPolicySelector is not a specific type. Please use one of the other overloads to register this type.
HResult = -2146233088 IsTransient = false Message = This type of IHostBufferPolicySelector is not a specific type. Please use one of the other overloads to register this type. Source = SimpleInjector
Stack Traces: in SimpleInjector.Advanced.DefaultConstructorResolutionBehavior.VerifyTypeIsConcrete (implementationType Type) InnerException:
The problem is not that one interface looks like this: SimpleInjector tries to find a binding for each individual interface; If I provided a dummy implementation for IHostBufferPolicySelector , it throws out some other interface, for example. IExceptionHandler etc.
There is a related thread HERE , but I'm not sure how it relates to SimpleInjector ? Self host is a console application with the following packages installed:
- Simple Injector ASP.NET Web API Integration v2.61
- Simple Injector Execution Context Coverage v2.61
- Simple Injector v2.61
- OWIN v1.0
- Microsoft.Owin v2.0.2
- Microsoft.Owin.Hosting v2.0.2
- Microsoft ASP.NET Web API 2.2 OWIN v5.2.2
- Microsoft ASP.NET Web API 2.2 OWIN Self Host v5.2.2
MaYaN source share