'System.Web.Security.MembershipUser.MembershipUser()' is inaccessibledue to its protection level

Discussion in 'ASP .Net Security' started by CSharpner, May 27, 2008.

  1. CSharpner

    CSharpner Guest

    I'm trying to make a customer MembershipProvider. While overrideing
    the CreateUser(...) method, I get the following compiler error that
    doesn't make any sense to me:

    'System.Web.Security.MembershipUser.MembershipUser()' is inaccessible
    due to its protection level

    Here's the relavent code:

    public override System.Web.Security.MembershipUser CreateUser(string
    username, string password, string email, string passwordQuestion,
    string passwordAnswer, bool isApproved, object providerUserKey, out
    System.Web.Security.MembershipCreateStatus status)
    {
    // do some stuff...
    MembershipUser muser = new MembershipUser(); // error is on this
    line.
    // do some more stuff.
    return muser;
    }

    I'm guessing I'm doing something wrong (I'm totally new to
    MembershpProviders) and may very well be going about this all wrong?

    Thanks
     
    CSharpner, May 27, 2008
    #1
    1. Advertising

  2. CSharpner

    Joy Guest

    RE: 'System.Web.Security.MembershipUser.MembershipUser()' is inaccessi

    Hi,
    This is because you are not using the default membership provider so you are
    not allowed to instantiate the MembershipUser object with no parameters.
    However you can do it the following way:

    MembershipUser mu = new MembershipUser("MaximumASPSqlMembershipProvider",
    null, null, null, null, null, true, true, System.DateTime.Now,
    System.DateTime.Now, System.DateTime.Now, System.DateTime.Now,
    System.DateTime.Now);

    Do let me know if it worked for you?


    regards,
    Joy


    "CSharpner" wrote:

    > I'm trying to make a customer MembershipProvider. While overrideing
    > the CreateUser(...) method, I get the following compiler error that
    > doesn't make any sense to me:
    >
    > 'System.Web.Security.MembershipUser.MembershipUser()' is inaccessible
    > due to its protection level
    >
    > Here's the relavent code:
    >
    > public override System.Web.Security.MembershipUser CreateUser(string
    > username, string password, string email, string passwordQuestion,
    > string passwordAnswer, bool isApproved, object providerUserKey, out
    > System.Web.Security.MembershipCreateStatus status)
    > {
    > // do some stuff...
    > MembershipUser muser = new MembershipUser(); // error is on this
    > line.
    > // do some more stuff.
    > return muser;
    > }
    >
    > I'm guessing I'm doing something wrong (I'm totally new to
    > MembershpProviders) and may very well be going about this all wrong?
    >
    > Thanks
    >
     
    Joy, May 27, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arjen
    Replies:
    1
    Views:
    5,065
    Arjen
    Jun 11, 2005
  2. sck10
    Replies:
    2
    Views:
    36,292
    sck10
    Aug 28, 2006
  3. Walter Wang [MSFT]
    Replies:
    2
    Views:
    1,261
    Walter Wang [MSFT]
    Jan 19, 2007
  4. Chip Gore
    Replies:
    6
    Views:
    2,202
    Ben Voigt [C++ MVP]
    Apr 10, 2008
  5. thunk
    Replies:
    0
    Views:
    489
    thunk
    Apr 1, 2010
Loading...

Share This Page