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.
peterthegreat
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
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
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.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
295 Points
910 Posts
Errors when trying to access MembershipUser property?
Apr 04, 2021 12:53 PM|peterthegreat|LINK
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
Contributor
4040 Points
1568 Posts
Re: Errors when trying to access MembershipUser property?
Apr 05, 2021 02:44 AM|yij sun|LINK
Hi peterthegreat,
Do you have a Custom Membership? If your Membership are customized,you could check whether your Membership class loss UserName property.
Do you have add namespace of 'System.Web.Security' ?
I suggest you could press 'Alt+ Enter' to use IntelliSense.
Best regards,
Yijing Sun
Member
295 Points
910 Posts
Re: Errors when trying to access MembershipUser property?
Apr 09, 2021 12:51 PM|peterthegreat|LINK
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.
Contributor
4040 Points
1568 Posts
Re: Errors when trying to access MembershipUser property?
Apr 13, 2021 09:10 AM|yij sun|LINK
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