views:

355

answers:

3

We have a live running business system with an error which occurs from time to time. The error is according to the stack trace comming from the asp.net membership provider. It does not seem to matter which user is currently logged on. As far as i can tell the asp.net membership tables in the database are fine.

Example of a code row generating the error:

if (Membership.GetUser() != null)

Error description:

Unable to cast object of type 'System.Int32' to type 'System.String'.

Stack Trace:

[InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.]
System.Data.SqlClient.SqlBuffer.get_String() +141
System.Data.SqlClient.SqlDataReader.GetString(Int32 i) +96
System.Web.Security.SqlMembershipProvider.GetNullableString(SqlDataReader reader, Int32 col) +35
System.Web.Security.SqlMembershipProvider.GetUser(String username, Boolean userIsOnline) +1110
System.Web.Security.Membership.GetUser(String username, Boolean userIsOnline) +82
System.Web.Security.Membership.GetUser() +19

Does anyone have an idea of what's wrong?


Update: We could not find a solution for this error. But eventually it disapeared.

Now when we migrated to another server this error totally cripples our application. I'm totally out of ideas :(

A: 

Post more of your code.

rlb.usa
It's not happening in his code. It looks like the MembershipProvider is crapping out.
Chuck Conway
A: 

Magnus, I recently came across the exact same error in my error logs on a production site. There were four errors from three different users, all happening within a one minute period. However, users can now log on without issue.

Did you ever unearth the cause of this error or arrive at any resolution?

Thanks

Scott Mitchell
A: 

I have encountered the same problem. Did anyone find a solution?

If it can somehow help to diagnose the problem just an info: I have MARS enabled in web.config (it solves some of the other problems I have, and I found it is mentioned in some questions regarding aformentioned GetUser() issue).