Today I ran into a unique problem where I got this error:
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.Parser Error Message: Exception has been thrown by the target of an invocation.Source Error:Line 46: <providers> Line 47: <clear /> Line 48: <add name="CustomRoleProvider" type="Grikly.WebUI.Providers.CustomRoleProvider" /> Line 49: </providers> Line 50: </roleManager>
There can be many solution for this ambiguous exception but in my specific case, I was missing a binding of a dependency on a service the roles provider uses. If you use dependency injection, ensure all your dependencies are bound.
I use dependency injection to inject an authentication service into my CustomRoleProvider by property injection. This authentication service also has dependencies on other services and repositories which uses constructor injection from Ninject. The problem is that I missed a binding for one of the dependencies of the authentication service. Now I am using WebActivator, which according to Haacked, allows you to run code way before Application_Start is called in which ninject bindings are normally executed. Because the RolesProvider is being initialized in the early stages of the pre-app start life-cycle through the web.config, the exception of having unbound dependencies will be thrown though the web.config as a parse error.
So this scenario requires that; your provider utilizes property injection via WebActivator[PreApplicationStartMethod] and the injected object also requires its own dependencies to be injected by constructor injection. When one or more of these constructor injected dependency is not bound, this error will be thrown.