Search code examples
c#silverlightroleprovider

Custom role provider web config error


I have written custom roleProvider for my Silverlight application. Unfortunately I'm getting an error while loading:

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="LanosRoleProvider" type="LANOS.Web.Security.LanosRoleProvider" applicationName="/" />
Line 49:       </providers>
Line 50:     </roleManager>


Source File: C:\path\LANOS\LANOS.Web\web.config    Line: 48 

This is definition of my role provider (class is inside Lanos.Web project):

namespace LANOS.Web.Security
{
    public class LanosRoleProvider : RoleProvider

I have really no clue why this does not work. Before adding it to my application I've tested it on some sample projects and it worked fine. Any ideas?

Or at least could you tell me how to show that exception info which is being thrown at the time of config load?


Solution

  • What version of ASP.NET are you running?

    I would suggest adding the assembly to the element like so if your assembly is LANOS.Web.Security:

    <add name="LanosRoleProvider" type="LANOS.Web.Security.LanosRoleProvider, LANOS.Web.Security" applicationName="/" connectionStringName="abcConnectionString" />
    

    UPDATED

    connectionStringName is a required attribute which is why the message is a parse error. This also means you will have to define a connection string in the section.

    <connectionStrings>
       <add name="abcConnectionString" connectionString="blah" />
     </connectionStrings>
    

    Hope this helps.