Need help related and microsoft.enterpriselibrary

Topics: Enterprise Library Core, Exception Handling Application Block, Security Application Block, Validation Application Block
Feb 18, 2009 at 7:51 AM
Dear Colleagues,

I am currently involved in the development of a web-based application which have the following specification:

Framework = .NET 2.0
Database = Microsoft SQL Server 2005

For the login management, LDAP - Active Directory is used.

There has been various type of error(s) occured at random frequency, such as mentioned in the end of this post.

For the meantime we overcome those error(s) by manually restart the application from IIS' Application Pool

I wonder if any of you have encounter this kind of error(s) before? If any, what solutions did you took? Any suggestions and help are appreciated.


Here's error from Event Log :
    Exception information:
    Exception type: InvalidCastException
    Exception message: Unable to cast object of type 'System.Int32' to type 'System.String'.

   at System.Data.SqlClient.SqlBuffer.get_String()
   at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
   at System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
   at System.Web.Security.RolePrincipal.IsInRole(String role)
   at Microsoft.Practices.EnterpriseLibrary.Security.WordExpression.Evaluate(IPrincipal principal)
   at Microsoft.Practices.EnterpriseLibrary.Security.RoleExpression.Evaluate(IPrincipal principal)
   at Microsoft.Practices.EnterpriseLibrary.Security.AuthorizationRuleProvider.Authorize(IPrincipal principal, String ruleName)
   at PageBase.IsUserAuthorizedForRule(String ruleName)
   at General_TugasDanPengerjaan.Page_Load(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.

And From application :
 Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

Feb 19, 2009 at 6:50 AM

When does this error happen? Any code snippet for this? On which call that this error happen?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Feb 20, 2009 at 5:13 AM
It happened randomly - FYI, I forgot to mention that sometimes the errors get fixed automatically even without restarting the application manually from IIS.

I can't give the code snippet since I don't know exactly which part of the code generates the error.

In this application every user have their own role (as applied from System.Web.Security)
Feb 20, 2009 at 5:42 AM
Edited Feb 20, 2009 at 5:44 AM
I could only make guesses here so far, there are no repro steps right?  Any more info as to when this more oftenly occurs?  Any user interaction which might be related?  The error explicitly states that there is an invalid cast exception,  couldn't it be that it might be dependent on something the user inputs or something you are retrieving based on user input? 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.