错误无法加载类型 'TrollMarket.web.MyRoleProvider.RoleSite'

Error Could not load type 'TrollMarket.web.MyRoleProvider.RoleSite'

如标题所说,roleManager 有错误

这是 web.config 代码:

<roleManager enabled="true" defaultProvider="MyProvider">
      <providers>
        <add name="MyProvider" type="TrollMarket.web.MyRoleProvider.RoleSite"/>
      </providers>
    </roleManager>

Here's the file placement

这里是 GetRoleForUser

public override string[] GetRolesForUser(string username) {
            AccountProvider accountProvider = new AccountProvider();
            string role = accountProvider.GetRole(username);
            string[] result = { role };
            return result;
        }

这里是 getrole 函数

public string GetRole(string username) {
        var user = trollContext.Account.FirstOrDefault(acc => acc.username == username);
        return user.role;
    }

请教我如何解决这个问题,这是我前辈的作业,由于这个错误我无法获得这个角色

这是错误

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: Could not load type 'TrollMarket.web.MyRoleProvider.RoleSite'.

Source Error:

Line 26:     <roleManager enabled="true" defaultProvider="MyProvider">
Line 27:       <providers>
Line 28:         <add name="MyProvider" type="TrollMarket.web.MyRoleProvider.RoleSite"/>
Line 29:       </providers>
Line 30:     </roleManager>

没关系,我找到了答案,对于那些有同样问题的人,请检查您的提供商命名空间并根据命名空间更改类型,如下所示

<add name="MyProvider" type="namespace.MyRoleProvider.RoleSite"/>