locked
Errors when trying to access MembershipUser property? RRS feed

  • Question

  • User1909155429 posted

    I get the following error messages:

    1 Error 'UserName' is not a member of 'MembershipUser'.

    Dim muc As MembershipUserCollection = Membership.GetAllUsers()

    For Each mu As MembershipUser In muc

    Dim userName As String = mu.UserName

    Next

    2 Error Value of type 'System.Web.Security.MembershipUser' cannot be converted to 'MembershipUser'.

    Dim USER As MembershipUser = Nothing

    Dim id As Guid

    USER = Membership.GetUser(ce)

    If USER IsNot Nothing Then id = Membership.GetUser(ce).ProviderUserKey

    End If

    Sunday, April 4, 2021 12:53 PM

Answers

All replies

  • User1535942433 posted

    Hi peterthegreat,

    1 Error 'UserName' is not a member of 'MembershipUser'.

    Dim muc As MembershipUserCollection = Membership.GetAllUsers()

    For Each mu As MembershipUser In muc

    Dim userName As String = mu.UserName

    Do you have a Custom Membership? If your Membership are customized,you could check whether your Membership class loss UserName property.

    2 Error Value of type 'System.Web.Security.MembershipUser' cannot be converted to 'MembershipUser'.

    Dim USER As MembershipUser = Nothing

    Dim id As Guid

    USER = Membership.GetUser(ce)

    If USER IsNot Nothing Then id = Membership.GetUser(ce).ProviderUserKey

    End If

    Do you have add namespace of 'System.Web.Security' ?

    I suggest you could press 'Alt+ Enter' to use IntelliSense. 

    Best regards,

    Yijing Sun
     

    Monday, April 5, 2021 2:44 AM
  • User1909155429 posted

    So there is nothing drastically wrong with the code? it is not a custom membership. This problem is a common error that kept raising when i re build site. I tried intellisense as you mention and  changed the code as recommended. It added an helper function. This may be the solution to the occurance. Although i cant clarify as there are numerous compile errors because i keep all files for reference purpose.

    Before i upgraded software to 2019 version i could run debugger even with all these errors in files. Ever since upgrade i no longer able to run debugger and notice i cant even update External style sheet to reflect changes to page style unless i add style rules to page itself?

    I guess it has to do with compile website. When i run website it ask if i want to run the last successful build. I always choose yes because it would not run otherwise. Is there anyway of getting round this problem or do i have to remove all the problem Files and Code faults.

     

    Friday, April 9, 2021 12:51 PM
  • User1535942433 posted

    Hi peterthegreat,

    I have some doubts:

    1.What's your namespace? Is System.Web.Security?

    2.What's your version of your framework?

    As far as I think,you have wrong package. There have username in the membership. You have conflicted with MembershipUser.

    I suggest you could remove all problems files and code faults.And then add the right MembershipUser package.

    More details,you could refer to below article:

    https://docs.microsoft.com/en-us/dotnet/api/system.web.security.membershipuser.username?view=netframework-4.8#System_Web_Security_MembershipUser_UserName

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 13, 2021 9:10 AM