Search code examples
.netasp.netcustom-membershipprovider

Custom Membership Provider - Error in my custom CreateUser Function with different parameters


I want to Create a new User using Custom Membership Provider but I don't want to use the default function that is created.

I don't want to use this

Public Overrides Function CreateUser(ByVal username As String,
                                         ByVal password As String,
                                         ByVal email As String,
                                         ByVal passwordQuestion As String,
                                         ByVal passwordAnswer As String,
                                         ByVal isApproved As Boolean,
                                         ByVal providerUserKey As Object,
                                         ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser
        Return Nothing
  End Function

Instead I want to use this

Public Overloads Function CreateUser(ByVal username As String,
                                         ByVal email As String,
                                         ByVal number As String,
                                         ByVal isApproved As Boolean,
                                          ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser

So when I use second option I get this squiggly lines saying "Reference to a non-shared member requires an object reference"

I referenced the .dll correctly like this

Imports CustomProviders

But when I try to create a user as shown in this below image it doesn't work. I am doing something clearly wrong. I don't know what it is.

enter image description here

Resolved: I found that the squiggly line was due to casting problem. I was referencing the class library member without casting in my web page code behind method. I think the other is also taken care off.


Solution

  • Hey, your code works (compiles okay with me) I just created a new membership provider and used your createuser method. It works Okay.

    If you just want to send less parameters, why dont you use optional parameter feature so that your caller's can still call the method with limited parameters. This way you will automatically get out of your problem (which I am not sure what is :) ?)

    http://msdn.microsoft.com/en-us/library/f25e2b6b(v=VS.100).aspx