I just tried to reproduce your issue by building a sample Web API project with the code in the articles you referenced, but it worked directly.
What I did was the following:
- Create an empty Web API project in Visual Studio.
- Added the
SimpleInjectorWebApiDependencyResolver
from here and registered (just as in your question). - Added the
SimpleInjectorActionFilterProvider
from here and registered it as shown just below the code snippet in that article. - Added your
InjectAttributePropertySelectionBehavior
and registered it like in your example. - Added your
InjectAttribute
. - Added your
MyActionFilterAttribute
(and overwrite theOnActionExecuting
method to be able to set a break point). - Added the
IMyRepository
and aMyRepositoryImpl
class. - Registered the
MyRepositoryImpl
by its interface in the container. - I decorated one of my Action methods with the
MyActionFilterAttribute
.
After doing this and running the application by calling the action, I see visual studio breaking inside the OnActionExecuting method with the MyRepository
property being set.
This is my configuration:
var container = new Container();
container.Options.PropertySelectionBehavior =
new InjectAttributePropertySelectionBehavior();
container.Register<IMyRepository, MyRepositoryImpl>();
GlobalConfiguration.Configuration.DependencyResolver =
new SimpleInjectorWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.Services.Remove(typeof(IFilterProvider),
GlobalConfiguration.Configuration.Services.GetFilterProviders()
.OfType<ActionDescriptorFilterProvider>().Single());
GlobalConfiguration.Configuration.Services.Add(
typeof(IFilterProvider),
new SimpleInjectorActionFilterProvider(container));