I have a very simple Web Api v2.2 self 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 appBuilder.UseWebApi(config);
I get the following exception:
A first chance exception of type 'SimpleInjector.ActivationException' occurred in SimpleInjector.dll
Additional information: The given type IHostBufferPolicySelector is not a concrete type. Please use one of the other overloads to register this type.
Complete Stack:
SimpleInjector.ActivationException occurred _HResult=-2146233088
_message=The given type IHostBufferPolicySelector is not a concrete type. Please use one of the other overloads to register this type.
HResult=-2146233088 IsTransient=false Message=The given type IHostBufferPolicySelector is not a concrete type. Please use one of the other overloads to register this type. Source=SimpleInjector
StackTrace: at SimpleInjector.Advanced.DefaultConstructorResolutionBehavior.VerifyTypeIsConcrete(Type implementationType) InnerException:
The problem is not that single interface it looks like SimpleInjector
is trying to find a binding for Every Single Interface; If I provide a dummy implementation for IHostBufferPolicySelector
it throws for some other interface e.g. IExceptionHandler
etc.
There is a related thread HERE but I am not sure how it relates to SimpleInjector
?
The Self host is a Console App which has the following packages installed:
- Simple Injector ASP.NET Web API Integration v2.61
- Simple Injector Execution Context Scoping 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
IHostBufferPolicySelector
? – MainesIHostBufferPoslicySelector
and what is the avaialble (default) implementation? – Aggression.ToString()
on that exception, you'll get all the relevant information from that exception that we need to help you. – Brandabrandais