Using Role Provider in an application

Topics: General Topic
Sep 11, 2012 at 5:09 PM
Edited Sep 11, 2012 at 5:16 PM

I'm attempting to use the role provider in an application. I have already got the authorization side of things working and now need to add role support. 

When I attempt to access the Role.Provider I get the following error:

Could not load type 'NetSqlAzMan.Providers.NetSqlAzManRoleProvider' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"NetSqlAzMan.Providers.NetSqlAzManRoleProvider"}

I'm thinking the issue is with my app.config...which looks like this:

 

  <system.web>
    <roleManager defaultProvider="NetSqlAzManRoleProvider" enabled="true" >
      <providers>
        <clear/>
        <add
        name="NetSqlAzManRoleProvider"
        type="NetSqlAzMan.Providers.NetSqlAzManRoleProvider"
        connectionStringName="PrimaryConnectionString" 
        storeName="MYSTORE" 
        applicationName="MyApp" 
        userLookupType="LDAP" 
        defaultDomain="" 
        UseWCFCacheService="False" />
      </providers>
    </roleManager>
  </system.web>

Code accessing the role provider is:

 Roles.Provider.IsUserInRole("userName", "roleName");

Any help would be greatly appreciated.

Sep 11, 2012 at 8:47 PM

In your config file, please try:

type="NetSqlAzMan.Providers.NetSqlAzManRoleProvider, NetSqlAzMan"

When you do Bin deployment, you need specify the Assembly name.

Let me know if it works.

Richard
Sep 11, 2012 at 9:55 PM

Richard,

Thank you for the quick reply.

That solved the problem...I had a feeling it would be something fairly simple...the exception suggested that it was looking for the correct thing just in the wrong place and I had no idea how to get it to look in the NetSqlAzMan dll for the provider.

Thanx again

Chuck