MyMembershipProvider class is not being recognized

MyMembershipProvider class is not being recognized

Old forum URL: forums.lhotka.net/forums/t/2689.aspx


Jav posted on Thursday, April 12, 2007

I fashioned MyMembershipProvider exactly after the PTMembershipProvider in the book, with one difference.  Since I use Web Application Projects, which do not have an App_Code folder, I have the class practically sitting next to the Web.config in the main directory.  The config entry is also almost verbatim the same as the book, except for the class name, of course.  Unfortunately, when logging in I keep getting a message that says, "MyMembershipProvider is not recognized".

Any ideas what I'm doing wrong

Jav

RockfordLhotka replied on Thursday, April 12, 2007

I haven't tried what you are doing - but you may consider creating a class library project and putting the code there. That way you can explicitly reference the object by assembly/type name since you control the whole thing.

Jav replied on Thursday, April 12, 2007

Thanks Rocky and Chris for your suggestions.

But I am at my wits' end.  Here is entry in my Config file.  This is the first entry in <system.web> section.

<membership defaultProvider="TessMembershipProvider">
   <providers>
    <clear />
    <add name="TessMembershipProvider"
      type="TessMembershipProvider, BizCommon"
      connectionStringName="EnvMembershipConnectionString"
      enablePasswordRetrieval="false"
      enablePasswordReset="true"
      requiresQuestionAndAnswer="true"
      requiresUniqueEmail="true"
      passwordFormat="Clear"/>
   </providers>
</membership>

Here is the totality of my TessMembershipProvider

Public Class TessMembershipProvider
    Inherits System.Web.Security.SqlMembershipProvider

    Public Overrides Function ValidateUser( _
      ByVal username As String, ByVal password As String) As Boolean

        If TessPrincipal.Login(username, password) Then
            System.Web.HttpContext.Current.Session("CslaPrincipal") = _
              Csla.ApplicationContext.User
            Return True

        Else
            Return False
        End If

    End Function
' Non Impelemnted Methods here
End Class

This class is in an assembly called BizCommon.  Here is what I see in the Asp.Net Configuration module when I click the Security Tab:

The following message may help in diagnosing the problem: Could not load type 'TessMembershipProvider' from assembly 'BizCommon'. (C:\MediWin\web.config line 40)

If I fully qualify the class name as Tess.TessMembershipProvider, the error changes to:

The following message may help in diagnosing the problem: Could not load type 'Tess.TessMembershipProvider' from assembly 'BizCommon'. (C:\MediWin\web.config line 40)

I can do this in the login page without error
      Dim prov As Tess.TessMembershipProvider

Amazingly, for months I have been using this very class with my Web Application Projects witout a single problem.  It all turned topsy turvy when I started using Ajax extensions.  I started getting some errors in the Source of my Forms.  A visit to the Ajax website suggested that I must create an Ajax Enabled Web Application instead of an ordinary App.  Since that time (48 hours ago) when I created a brand new Ajax Enabled Application and painfully copied back all my stuff, I have not been able to run the App beyond a look at the Login page. Misery unbounded.

Jav
 

skagen00 replied on Friday, April 13, 2007

You're inheriting from System.Web.Security.SqlMembershipProvider instead of simply specifying the interface of MembershipProvider.

Have you done this on purpose? Have you run the utility against the database to create all the necessary tables and stored procedures?

In the book, Rocky inherits MembershipProvider. My custom class does as well. I wonder if your problem is related to your inheritance?

If you are inheriting from SqlMembershipProvider on purpose (assumedly to try to leverage the tables/stored procedures/implementation) have you tried changing your Web.config to temporarily use the SqlMembershipProvider as your default provider? If you've run your utility and your Web.config is set to the SqlMembershipProvider and you still have problems getting into the utility, I would start to wonder if you have something going on with your Web.config that isn't quite right.

Jav replied on Friday, April 13, 2007

Chris,

I think you are on to something here.  I pulled out a backup of my old code this morning to see how I had it set up when it was working, and my config file was indeed different. it was:

  <membership defaultProvider="TessMembershipProvider">
   <providers>
    <clear />
    <add name="TessMembershipProvider"
       type="System.Web.Security.SqlMembershipProvider"
       connectionStringName="EnvMembershipConnectionString"
       enablePasswordRetrieval="false"
       enablePasswordReset="true"
       requiresQuestionAndAnswer="true"
       requiresUniqueEmail="true"
       passwordFormat="Clear"/>
   </providers>
  </membership>

I am actually using the aspnetdb database.  While at the present time I am only using the basic functionalty, I did find some of the other capabilities intriguing for playing around with in the future.

Thank you for your help.  This forum - if we didn't have this kind of help, I don't know what we would do at times like this.  Thanks again to you and to Rocky.

I am sorry for duplicating the previous message while trying to edit it, I tried deleting one but the forum wouldn't let me.

Jav

skagen00 replied on Friday, April 13, 2007

Awesome. I'm glad I could help and I couldn't agree more - this forum is one of the reasons I settled on CSLA in the first place.

Enjoy your weekend.

Chris

 

Jav replied on Thursday, April 12, 2007

Thanks Rocky and Chris for your suggestions.

But I am at my wits' end.  Here is entry in my Config file.  This is the first entry in <system.web> section.

<membership defaultProvider="TessMembershipProvider">
   <providers>
    <clear />
    <add name="TessMembershipProvider"
      type="TessMembershipProvider, BizCommon"
      connectionStringName="EnvMembershipConnectionString"
      enablePasswordRetrieval="false"
      enablePasswordReset="true"
      requiresQuestionAndAnswer="true"
      requiresUniqueEmail="true"
      passwordFormat="Clear"/>
   </providers>
</membership>

Here is the totality of my TessMembershipProvider

Public Class TessMembershipProvider
    Inherits System.Web.Security.SqlMembershipProvider

    Public Overrides Function ValidateUser( _
      ByVal username As String, ByVal password As String) As Boolean

        If TessPrincipal.Login(username, password) Then
            System.Web.HttpContext.Current.Session("CslaPrincipal") = _
              Csla.ApplicationContext.User
            Return True

        Else
            Return False
        End If

    End Function
' Non Impelemnted Methods here
End Class

This class is in an assembly called BizCommon.  Here is what I see in the Asp.Net Configuration module when I click the Security Tab:

The following message may help in diagnosing the problem: Could not load type 'TessMembershipProvider' from assembly 'BizCommon'. (C:\MediWin\web.config line 40)

If I fully qualify the class name as Tess.TessMembershipProvider, the error changes to:

The following message may help in diagnosing the problem: Could not load type 'Tess.TessMembershipProvider' from assembly 'BizCommon'. (C:\MediWin\web.config line 40)

I can do this in the login page without error
      Dim prov As Tess.TessMembershipProvider

Amazingly, for months I have been using this very class with my Web Application Projects witout a single problem.  It all turned topsy turvy when I started using Ajax extensions.  I started getting some errors in the Source of my Forms.  A visit to the Ajax website suggested that I must create an Ajax Enabled Web Application instead of an ordinary App.  Since that time (48 hours ago) when I created a brand new Ajax Enabled Application and painfully copied back all my stuff, I have not been able to run the App beyond a look at the Login page. Misery unbounded.

Jav
 

skagen00 replied on Thursday, April 12, 2007

Hey Jav -

I'm not entirely sure what you did for your custom membership provider, but for mine, I essentially created one that "wraps" another membership provider to leverage all the implementation of it (specifically the SqlMembershipProvider) but it remotes over to the app server to invoke the membership API there. In that case, I need to provide the configuration in the Web.config for the membership provider in the remoting directory's Web.config too.

Both my web directory's and remoting directory's web.config have similar entries within system.web for configuring the membership provider, except that since the web app doesn't use DB settings, I don't need the connection string in the web directory's web.config.

(I happen to use the sample code they released for the SqlMembershipProvider as I liked to see it through the debug - but I could have just wrapped the one in the .Net framework too).

So like I said, I'm not sure exactly what your membership provider is doing, but in case this helps I thought I'd pass it along.

Within the <system.web> tag I have:

  <membership defaultProvider="CslaMembershipProvider">
   <providers>
    <!-- Note that the connection string is irrelevant on the client side Web app -->
    <!-- It is supplied on the remoting site's Web config. SqlMembershipProvider balks if it's not there. -->
    <clear/>
    <add name="CslaMembershipProvider" type="xxx.CoreSystem.Library.CslaMembershipProvider" connectionStringName="xxx" functionalProvider="Microsoft.Samples.SqlMembershipProvider" passwordFormat="Encrypted" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="6" enablePasswordRetrieval="false" requiresUniqueEmail="true" requiresQuestionAndAnswer="true" enablePasswordReset="true" description="Csla enabled membership provider"/>
   </providers>
  </membership>

Good luck,

Chris

 

Copyright (c) Marimer LLC