C# 使用MVC 2.0网络配置的自定义角色提供程序
我有一个自定义会员资格提供商和一个自定义角色提供商。我通过创建实现MembershipProvider类的SimpleMembershipProvider类来创建自定义MembershipProvider。之后,我更改了web.config并开始工作 所以我用同样的方法创建了一个自定义角色提供者。没有什么特别的,只是创建一个实现RoleProvider类的SimpleRoleProvider类。但是,当我更改web.config文件并运行解决方案时,我收到以下错误消息: Web.ConfigC# 使用MVC 2.0网络配置的自定义角色提供程序,c#,asp.net,asp.net-mvc,web-config,C#,Asp.net,Asp.net Mvc,Web Config,我有一个自定义会员资格提供商和一个自定义角色提供商。我通过创建实现MembershipProvider类的SimpleMembershipProvider类来创建自定义MembershipProvider。之后,我更改了web.config并开始工作 所以我用同样的方法创建了一个自定义角色提供者。没有什么特别的,只是创建一个实现RoleProvider类的SimpleRoleProvider类。但是,当我更改web.config文件并运行解决方案时,我收到以下错误消息: Web.Config &
<membership defaultProvider="DashboardMembershipProvider">
<providers>
<clear/>
<add name="SimpleMembershipProvider"
type="Dashboard.Web.Controlling.Account.SimpleMembershipProvider" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="DashboardRoleProvider">
<providers>
<clear/>
<add name="DashboardRoleProvider"
type="Dashboard.Web.Controlling.Account.DashboardRoleProvider" />
</providers>
</roleManager>
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: No parameterless constructor defined for this object.
Source Error
Line 78: <add name="SimpleRoleProvider"
Line 79: type="Dashboard.Web.Controlling.Account.SimpleRoleProvider" />
配置错误
描述:处理服务此请求所需的配置文件时出错。请查看下面的特定错误详细信息,并适当修改配置文件。
分析器错误消息:没有为此对象定义无参数构造函数。
源错误
第78行:
所以我在网上搜索。并在type属性上尝试,该属性会生成以下错误:
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 file or assembly 'Dashboard.Web.Controlling.Account' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 78: <add name="SimpleRoleProvider"
Line 79: type="Dashboard.Web.Controlling.Account.SimpleRoleProvider,Dashboard.Web.Controlling.Account" />
配置错误
描述:处理服务此请求所需的配置文件时出错。请查看下面的特定错误详细信息,并适当修改配置文件。
分析器错误消息:无法加载文件或程序集“Dashboard.Web.Controlling.Account”或其依赖项之一。系统找不到指定的文件。
源错误:
第78行:
关于如何让CustomRoleProvider正常工作,有什么建议吗?
非常感谢您的帮助
<add name="SimpleRoleProvider" type="Dashboard.Web.Controlling.Account.SimpleRoleProvider,Dashboard.Web.Controlling.Account" />
第一个逗号后的类型部件是程序集名称,您确定程序集名称不仅仅是Dashboard.Web吗
右键单击项目并选择properties,它将找到您的程序集名称。从第一个例外情况开始,DashboardRoleProvider需要具有无参数构造函数。否则,框架将无法实例化角色提供程序 在第二个示例中,您可能希望改用完全限定的程序集名称 迈克尔