The given type ModelMetadataProvider is not a concrete type. Please use one of the other overloads to register this type.

Nov 6, 2014 at 2:46 PM
Edited Nov 6, 2014 at 2:50 PM
First, sorry for my poor English :).

Second, I don't understand why actually I get a Exception "The given type ModelMetadataProvider is not a concrete type. Please use one of the other overloads to register this type." on first Html helper of the .cshtml page.

I was missing some on the Simple Injector integration of my MVC 5 application?

Ugo
Coordinator
Nov 6, 2014 at 2:48 PM
Can you post the full stack trace that comes with this exception?
Nov 6, 2014 at 3:02 PM
I think I have some more serious problem...
I had many exception in the IntelliTrace.
"The given type IControllerFactory is not a concrete type. Please use one of the other..."
"The given type IControllerActivator is not a concrete type..."
"The given type ITempDataProviderFactory is not a concrete type..."
"The given type ITempDataProvider is not a concrete type..."
"The given type IAsyncActionInvoker is not a concrete type..."
...

Uhhhh
Coordinator
Nov 6, 2014 at 3:09 PM
Without a proper full stack trace (of the exception and ALL inner exceptions) there's not much to reason about.
Nov 6, 2014 at 3:28 PM
Sorry...

Example of first exception on SimpleInjector.dll:
SimpleInjector.Advanced.DefaultConstructorResolutionBehavior.VerifyTypeIsConcrete(System.Type implementationType = {sconosciuto})
SimpleInjector.Advanced.DefaultConstructorResolutionBehavior.GetConstructor(System.Type serviceType = {sconosciuto}, System.Type implementationType = {sconosciuto})
SimpleInjector.ContainerOptions.SelectConstructor(System.Type serviceType = {sconosciuto}, System.Type implementationType = {sconosciuto})  
SimpleInjector.Container.IsConstructableType(System.Type serviceType = {sconosciuto}, System.Type implementationType = {sconosciuto}, out string errorMessage = {sconosciuto})
SimpleInjector.Container.IsConcreteConstructableType(System.Type concreteType = {sconosciuto})
SimpleInjector.Container.TryBuildInstanceProducerForConcreteUnregisteredType(System.Type concreteType = {sconosciuto})  
c__DisplayClass29.AnonymousMethod() 
SimpleInjector.Container.BuildInstanceProducerForType(System.Type serviceType = {sconosciuto}, System.Func<SimpleInjector.InstanceProducer> tryBuildInstanceProducerForConcreteType = {sconosciuto})
SimpleInjector.Container.BuildInstanceProducerForType(System.Type serviceType = {sconosciuto}, bool autoCreateConcreteTypes = {sconosciuto})    
c__DisplayClass1a.AnonymousMethod() 
SimpleInjector.Container.GetInstanceProducerForType(System.Type serviceType = {sconosciuto}, System.Func<SimpleInjector.InstanceProducer> buildInstanceProducer = {sconosciuto})    
SimpleInjector.Container.GetRegistrationEvenIfInvalid(System.Type serviceType = {sconosciuto}, bool autoCreateConcreteTypes = {sconosciuto})    
SimpleInjector.Container.GetRegistration(System.Type serviceType = {sconosciuto}, bool throwOnFailure = {sconosciuto}, bool autoCreateConcreteTypes = {sconosciuto})    
SimpleInjector.Container.GetRegistration(System.Type serviceType = {sconosciuto}, bool throwOnFailure = {sconosciuto})  
SimpleInjector.Container.GetRegistration(System.Type serviceType = {sconosciuto})   
SimpleInjector.Container.System.IServiceProvider.GetService(System.Type serviceType = {sconosciuto})    
Continue in SimpleInjector.Integration.Web.Mvc.dll
   SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type serviceType = {sconosciuto})  C#
And in System.Web.Mvc.dll
    System.Web.Mvc.DependencyResolverExtensions.GetService(System.Web.Mvc.IDependencyResolver resolver = {sconosciuto}) 
System.Web.Mvc.SingleServiceResolver`1.GetValueFromResolver()   
System.Lazy`1.CreateValue() 
System.Lazy`1.LazyInitValue()   
System.Lazy`1.Value.get()   
System.Web.Mvc.SingleServiceResolver`1.Current.get()    
System.Web.Mvc.ControllerBuilder.GetControllerFactory() 
System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(System.Web.Routing.RequestContext requestContext = {sconosciuto})    
System.Web.Mvc.MvcRouteHandler.GetHttpHandler(System.Web.Routing.RequestContext requestContext = {sconosciuto}) 
System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(System.Web.Routing.RequestContext requestContext = {sconosciuto})    
In System.Web.dll
    System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(System.Web.HttpContextBase context = {sconosciuto}) 
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(object sender = {sconosciuto}, System.EventArgs e = {sconosciuto}) 
SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
System.Web.HttpApplication.ExecuteStep(IExecutionStep step = {sconosciuto}, ref bool completedSynchronously = {sconosciuto})    
PipelineStepManager.ResumeSteps(System.Exception error = {sconosciuto}) 
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context = {sconosciuto}, System.AsyncCallback cb = {sconosciuto}) 
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr = {sconosciuto}, System.Web.HttpContext context = {sconosciuto})
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer = {sconosciuto}, System.IntPtr nativeRequestContext = {sconosciuto}, System.IntPtr moduleData = {sconosciuto}, int flags = {sconosciuto})
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer = {sconosciuto}, System.IntPtr nativeRequestContext = {sconosciuto}, System.IntPtr moduleData = {sconosciuto}, int flags = {sconosciuto})
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer = {sconosciuto}, System.IntPtr nativeRequestContext = {sconosciuto}, System.IntPtr moduleData = {sconosciuto}, int flags = {sconosciuto})
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer = {sconosciuto}, System.IntPtr nativeRequestContext = {sconosciuto}, System.IntPtr moduleData = {sconosciuto}, int flags = {sconosciuto})
Coordinator
Nov 6, 2014 at 3:43 PM
The exceptions you are showing are 'first chance exceptions'. These exceptions are thrown by Simple Injector but they are caught and processed by Simple Injector and they won't bubble up the call stack. It is possible that you see them in some debugger output window, but they are quite normal and nothing to worry about.

Are you experiencing any kind of problem because of these exceptions?
Nov 6, 2014 at 3:52 PM
No, but I was worry for the long list... :)
By the way is possible to not show the first change exceptions on IntelliTrace of Visual Studio 2013?
Coordinator
Nov 6, 2014 at 8:09 PM
I have no experience with IntelliTrace at all, so I can't comment on that. However, what I do know is that it is normal for MVC to query the IDependencyResolver for all kinds of interfaces. Simple Injector tries to resolve them internally and that's when the exception occurs. This information however is cached internally in Simple Injector, so the exception won't occur again. And in the case of MVC, MVC will cache that information as well, so MVC won't query the IDependencyResolver again (for most types).
Nov 6, 2014 at 8:27 PM
Thank you for your exhaustive answer.