我有一个自定义MembershipProvider和一个自定义RoleProvider。我通过创建实现MembershipProvider类的SimpleMembershipProvider类创建了自定义MembershipProvider。在那之后,我改变了我的web.config并开始工作。
因此,我使用了相同的方法来创建自定义RoleProvider。没什么特别的,只是创建了一个实现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" />所以我在网上搜索了一下。并在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" />关于如何让这个CustomRoleProvider工作,有什么建议吗?任何帮助都是非常感谢的!
发布于 2010-03-12 08:58:38
从你得到的第一个异常开始,DashboardRoleProvider需要有一个无参数的构造函数。否则,框架将无法实例化您的角色提供程序。
在第二个示例中,您可能希望改用完全限定的程序集名称。
迈克尔
发布于 2010-03-12 04:41:37
<add name="SimpleRoleProvider" type="Dashboard.Web.Controlling.Account.SimpleRoleProvider,Dashboard.Web.Controlling.Account" />第一个逗号后面的类型部分是程序集名称,您确定程序集名称不只是Dashboard.Web吗?
右键单击项目并选择属性,这将找到您的程序集名称。
https://stackoverflow.com/questions/2427718
复制相似问题