-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No registration for type IEnumerable<IFilterProvider> could be found. #105
Comments
Please update to the SimpleInjector.Integration.Web.Mvc NuGet package version 3.0.2. |
My configuration looked like the below after upgrading and that is when stuff broke and I rolled back. My current working configuration is (below) so I'll try to upgrade to the SimpleInjector.Integration.Web.Mvc NuGet package version 3.0.2 |
I just double checked by pulling in version 3.0.2 of the SimpleInjector.Integration.Web.Mvc NuGet package, but the problem is really solved in that version. If I roll back to 3.0.1 the problem reappears again. I expect that somehow an old version is cached on your machine. Make sure that the project references version 3.0.2 (you can check this by going to properties after right clicking on the assembly in the project's references list). |
Upgrading to 3.0.3, my MVC project generated a similar error. Do you think the problem came back? |
Can you post a full stack trace of the exception and inner exceptions? |
@bjm3819, you are using your own custom Please use the IEnumerable<object> IDependencyScope.GetServices(Type serviceType) {
Type collectionType = typeof(IEnumerable<>).MakeGenericType(serviceType);
var services = (IEnumerable<object>)this.ServiceProvider.GetService(collectionType);
return services ?? Enumerable.Empty<object>();
} @utkuerd, are you using your own custom implementation as well? |
Ok, here is some more detail for my case: I was at 2.5.2 and upgraded it to 3.0.3. I do not have a custom IDependencyResolver implementation. I'm using SimpleInjector with ASP.NET MVC 5.2.0. (Tried upgrading it to 5.2.3 too, same result). There seems nothing related to my code in the stack trace. I've also applied your workaround at #98 and it was a success. After inserting Here is my exception details: SimpleInjector.ActivationException occurred Message: A first chance exception of type 'SimpleInjector.ActivationException' occurred in SimpleInjector.dll Additional information: No registration for type IEnumerable could be found. Stack Trace: [ActivationException: No registration for type IEnumerable could be found.] SimpleInjector.Container.ThrowMissingInstanceProducerException(Type serviceType) +202 SimpleInjector.Container.GetInstanceFromProducer(InstanceProducer instanceProducer, Type serviceType) +48 SimpleInjector.Container.GetInstanceForRootType(Type serviceType) +95 SimpleInjector.Container.GetInstance(Type serviceType) +99 SimpleInjector.Container.GetAllInstances(Type serviceType) +139 System.Web.Mvc.DelegateBasedDependencyResolver.GetServices(Type type) +47 System.Web.Mvc.DependencyResolverExtensions.GetServices(IDependencyResolver resolver) +116 System.Web.Mvc.MultiServiceResolver.GetCombined(IList`1 items, IDependencyResolver resolver) +125 System.Web.Mvc.FilterProviderCollection.get_CombinedItems() +90 System.Web.Mvc.FilterProviderCollection.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +194 System.Web.Mvc.ControllerActionInvoker.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +62 System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +436 System.Web.Mvc.Controller.b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +82 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73 System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +105 System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +588 System.Web.Mvc.Controller.b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +47 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +65 System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +139 System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +484 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +50 System.Web.Mvc.MvcHandler.b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +98 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73 System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +106 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +446 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 |
@utkuerd, there actually is something related to your code in the stack trace, but you have to know what to look for. Here is the clue:
The In other words, you are either calling: DependencyResolver.SetResolver(((IServiceProvider)container).GetService, container.GetAllInstances) or you are calling: DependencyResolver.SetResolver(container); Both are not valid in Simple Injector 3 anymore. The call DependencyResolver.SetResolver(((IServiceProvider)container).GetService,
type => (IEnumerable<object>)container.GetService(typeof(IEnumerable<>).MakeGenericType(type))
?? Enumerable.Empty<object>()); |
Thanks for clarificaton. I had suspected something breaking down with my v 2.x style use of DelegateBasedDependencyResolver, but I couldn't have figured out how things bind together by examining stack trace. That cleared everything. A quick question from my curiosity, any plans to provide a mechanism to automatically adapt the new behavior of Container to MVC? For example in the SimpleInjectorDependencyResolver class in MVC Integration package? |
@utkuerd: The |
Oh great, I'll go that way. Thanks for the answers. |
Fixed in v3.0.2. |
I'm using the version 3.2.0.0 and I'm having the same error:
Stack Trace:
|
@jabreuar, what IDependencyResolver did you register? Can you show the code to reproduce? |
I'm having the same issue as @jabreuar. My registration is extremely simple:
|
Woops, I figured out my problem. The last line is supposed to be:
I wonder why the compiler let me pass the container object, it doesn't implement IDependencyResolver as far as I can see. |
The MVC designers tried to be smart and implemented some sort of duck typing. When the supplied object contains a In Simple Injector v3 however, the behavior of |
Yeah, it's very strange. Global.asax, in general, has some crazy dynamic compilation magic going on. |
Updated from SimpleInjector 3.0.0 to SimpleInjector 3.0.1 is breaking the MVC web site.
There are several types that are not getting registered such as
IEnumerable<IFilterProvider>
andIEnumerable<ModelValidatorProvider>
, etc.The text was updated successfully, but these errors were encountered: