簡體   English   中英

自定義角色提供程序Web配置錯誤

[英]Custom role provider web config error

我已經為我的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

我真的不知道為什么這行不通。 在將其添加到我的應用程序之前,我已經在一些示例項目中對其進行了測試,並且工作正常。 有任何想法嗎?

或者至少您能告訴我如何顯示在配置加載時拋出的異常信息嗎?

您正在運行什么版本的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>

希望這可以幫助。

剛遇到這個問題,我的問題是我正在為自定義角色提供程序使用的服務使用屬性注入。 該服務還要求其依賴項由構造函數注入。 我錯過了這些構造函數依賴項之一的綁定,這導致拋出此模棱兩可的錯誤。 我試圖在這里解釋這一點

我希望它能像我一樣幫助來自Google的人。

這發生在我身上,因為在RoleProvider的構造函數中引發了異常。 檢查構造函數的調用鏈和私有成員的默認分配。

我的特定問題是由構造函數中EntityFramework的問題引起的。

清除提供程序中的所有構造函數代碼,然后進行測試以查看錯誤是否消失,並且您會知道自己處在正確的軌道上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM