Solved

Custom MembershipProvider - web.config error: Cannot create an abstract class.

Posted on 2006-11-17
2
1,358 Views
Last Modified: 2012-05-05
App_Code:
HamotMembershipProvider.vb -

Imports Microsoft.VisualBasic
Imports System.Data

Public MustInherit Class HamotMembershipProvider
    Inherits System.Web.Security.MembershipProvider
    Private hfunctions As New hamot_functions
    Private connStr As String = hfunctions.sConnectionString
    Private comm As New Data.OleDb.OleDbCommand

    Private _requiresQuestionAndAnswer As Boolean
    Private _minRequiredPasswordLength As Integer

....snip....

    Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
        Dim sSql As String = "SELECT userid FROM dbo.sys_users WHERE user_name='" & username & "' AND password='" & password & "'"
        Dim drUserCredentials As Data.SqlClient.SqlDataReader = hfunctions.get_datareader(connStr, sSql)
        Dim bReturn As Boolean = False

        If Not IsNothing(drUserCredentials) Then
            If drUserCredentials.HasRows Then
                bReturn = True
            End If
        End If
        drUserCredentials.Close()
        drUserCredentials = Nothing

        ValidateUser = bReturn
    End Function

...snip..
End Class

================================
web.config-

      <system.web>
            <authentication mode="Forms">
                  <forms loginUrl="default.aspx" name=".ASPXFORMSAUTH" />
            </authentication>
            <membership defaultProvider="HamotMembershipProvider">
                  <providers>
                        <add name="HamotMembershipProvider" type="System.Web.Security.MembershipProvider" />
                  </providers>
            </membership>

...snip..
================================
Error Output:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Cannot create an abstract class.

Source Error:


Line 21:             <membership defaultProvider="HamotMembershipProvider">
Line 22:                   <providers>
Line 23:                         <add name="HamotMembershipProvider" type="System.Web.Security.MembershipProvider" />
Line 24:                   </providers>
Line 25:             </membership>
0
Comment
Question by:EchoBinary
2 Comments
 
LVL 12

Accepted Solution

by:
AGBrown earned 500 total points
ID: 17972396
If you implement your own membership provider, it _must_ be an instantiable class, i.e., not abstract. So you need to get rid of the MustInherit in your class definition above.

Is that possible, and does that help?

Andy
0
 
LVL 3

Expert Comment

by:rundkaas
ID: 17974418
Your problem as far as I can see it, is that the type is wrong!
You are using the following: type="System.Web.Security.MembershipProvider"
but this should realy be type="myNameSpace.HamotMembershipProvider", where myNameSpace is the namespace where HamotMembershipProvider resides.

What you are doing here is to load a new instace of the abstract System.Web.Security.MembershipProvider ,an calling the reference: "HamotMembershipProvider"
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question