自定义角色提供程序web配置错误

本文关键字:web 配置 错误 程序 角色 自定义 | 更新日期: 2023-09-27 18:08:15

我已经为我的Silverlight应用程序编写了自定义角色提供者。不幸的是,我得到一个错误,而加载:

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 

这是我的角色提供者的定义(类在Lanos中)。Web项目):

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

我真的不知道为什么这不起作用。在将它添加到我的应用程序之前,我已经在一些示例项目上测试了它,它工作得很好。什么好主意吗?

或者至少你能告诉我如何显示在配置加载时抛出的异常信息吗?

自定义角色提供程序web配置错误

什么版本的ASP。NET你在运行吗?

我建议将程序集添加到元素中,如果您的程序集是LANOS.Web.Security:

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

connectionStringName是必需的属性,这就是为什么消息是解析错误。这也意味着您必须在节中定义一个连接字符串。

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

刚刚遇到这个问题,我的问题是,我正在使用属性注入自定义角色提供者使用的服务。此服务还需要通过构造函数注入其依赖项。我错过了这些构造函数依赖关系之一的绑定,这导致了这个模糊的错误被抛出。我试着在这里解释这个

我希望它能帮助像我一样来自谷歌的人。

发生在我身上是因为在我的RoleProvider的构造函数中抛出了一个异常。检查构造函数调用链和private成员的默认赋值。

我的特殊问题是由构造函数中EntityFramework的问题引起的。

清除提供程序中的所有构造函数代码并测试,看看错误是否消失,你就知道你在正确的轨道上。