自定义角色提供程序 Web 配置错误
我已经为我的 Silverlight 应用程序编写了自定义 roleProvider。 不幸的是,我在加载时遇到错误:
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
我真的不知道为什么这不起作用。在将其添加到我的应用程序之前,我已经在一些示例项目上对其进行了测试,并且运行良好。有什么想法吗?
或者至少你能告诉我如何显示在配置加载时抛出的异常信息吗?
I have written custom roleProvider for my Silverlight application.
Unfortunately I'm getting an error while loading:
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
This is definition of my role provider (class is inside Lanos.Web project):
namespace LANOS.Web.Security
{
public class LanosRoleProvider : RoleProvider
I have really no clue why this does not work. Before adding it to my application I've tested it on some sample projects and it worked fine. Any ideas?
Or at least could you tell me how to show that exception info which is being thrown at the time of config load?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这发生在我身上,因为我的 RoleProvider 的构造函数中抛出了异常。
检查您的构造函数调用链和私有成员默认分配。
我的特殊问题是由构造函数中 EntityFramework 的问题引起的。
清除提供程序中的所有构造函数代码并进行测试以查看错误是否消失,您就会知道自己走在正确的轨道上。
This happened to me because an exception was thrown in the constructor of my RoleProvider.
Check your constructors call chain and and private member default assignments.
My particular issue was caused by a problem with EntityFramework in the constructor.
Clear out any constructor code in the provider and test to see if the error goes away and you'll know you are on the right track.
您运行的 ASP.NET 版本是什么?
如果您的程序集是 LANOS.Web.Security,我建议将程序集添加到元素中,如下所示:
UPDATED
connectionStringName 是必需属性,这就是该消息是解析错误的原因。这也意味着您必须在该部分中定义一个连接字符串。
希望这有帮助。
What version of ASP.NET are you running?
I would suggest adding the assembly to the element like so if your assembly is LANOS.Web.Security:
UPDATED
connectionStringName is a required attribute which is why the message is a parse error. This also means you will have to define a connection string in the section.
Hope this helps.
刚刚遇到这个问题,我的问题是我正在为自定义角色提供程序使用的服务使用属性注入。该服务还需要通过构造函数注入其依赖项。我错过了这些构造函数依赖项之一的绑定,这导致抛出这个不明确的错误。我尝试在此处解释这一点。
我希望它能帮助像我一样来自谷歌的人。
Just ran into this problem and my problem was that I was using property injection for a service used by the Custom Roles Provider. This service also required its dependencies to be injected by constructor. I missed a binding of one of these constructor dependencies which caused this ambiguous error to be thrown. I tried explaining this on here.
I hope it helps people coming from google like I did.