Author: shapper | Posted on: 11/1/2008 10:30:09 AM | Views : 472

 Hello,

I have created a class that inherits MembershipUser:
public class UserHelper : MembershipUser {
...

Then I am creating a user as follows:
UserHelper user = (UserHelper)Membership.CreateUser("me", "pass", "me@domain.com", null, null, true, null, out status);

Membership.CreateUser returns a MembershipUser

But I get an error:
Unable to cast object of type 'System.Web.Security.MembershipUser' to type 'MyApp.Security.Membership.UserHelper'.

If I don't cast it, which means, using:
UserHelper user = Membership.CreateUser("me", "pass", "me@domain.com", null, null, true, null, out status);

It does not compile and I get the error:
Cannot implicitly convert type 'System.Web.Security.MembershipUser' to 'MyApp.Security.Membership.UserHelper'. An explicit conversion exists (are you missing a cas ...

Go to the complete details ...