Results 1 to 4 of 4

Thread: Using Custom Membership Provider in WinForms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2008
    Posts
    185

    Using Custom Membership Provider in WinForms

    Hello,

    I would like to use my custom membership provider (which is working in my asp.net application) in my windows forms application.

    I thought this would be relatively straight forward, and followed these steps:

    1. Copied MembershipProvider class into my application.
    2. Add reference to System.Web
    3. Create app.config with membership settings i.e:
    Code:
    <configuration>
      <configSections>
      </configSections>
      
        <system.web>
          <authentication mode="Forms">
            <forms name=".ASPXFORMSAUTH" />
          </authentication>
          <machineKey validationKey="*****" /> <!-- Removed for example -->
          <membership defaultProvider="CurveMembershipProvider">
            <providers>
              <clear />
              <add name="CiseroMembershipProvider" 
                   type="CiseroMembershipProvider"
                   applicationName="CurveWin"
                   connectionStringName="CurveWin"
                   passwordFormat="Hashed"/>
            </providers>
          </membership>
        </system.web>
    I have some code where I need to validate the user against the database:
    Code:
     Public Function RenewLicense(ByVal username As String, _
                                     ByVal password As String) As Boolean
    
            ' TODO: validate user, get license key and expiry date
    
            If Membership.ValidateUser(username, password) Then
                Dim User As CiseroMembershipUser = System.Web.Security.Membership.GetUser
                License = New License
    Membership.ValidateUser is a member of system.web.security. My class method for ValidateUser should be called here, but I get the following message:

    Could not load type 'CiseroMembershipProvider' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

    This also happened at one time in my asp.net application, but was easily solved by moving the class to the app_code folder.

    I have tried changing the type setting of the membership provider to MyApp.CiseroMembershipProvider, but I still get the error.

    I also noticed that the class initialize method was not being called, so I added the following:

    Code:
    System.Web.Security.Membership.Provider.Initialize("CiseroMembershipProvider", ConfigurationManager.AppSettings)
    The same error occurs.

    Does anyone know a solution?



    Thanks for reading

  2. #2
    New Member
    Join Date
    Oct 2010
    Posts
    1

    Re: Using Custom Membership Provider in WinForms

    Hi,

    Could you solve this issue?
    I have same error in my winform app.
    Any information would be apreciated.

    Regards,
    Satomi

  3. #3
    New Member
    Join Date
    Jul 2011
    Posts
    1

    Re: Using Custom Membership Provider in WinForms

    hello, still no one knows?

    Regards...SiViN

  4. #4
    New Member
    Join Date
    Sep 2011
    Posts
    1

    Re: Using Custom Membership Provider in WinForms

    I finally found the answer from http://juniorpropellerhead.blogspot....-winforms.html

    For me, it was changing the provider string from

    Code:
     <add name=MyCustomProvider" type="MyCustomLibrary.Provider.CustomProvider" ...
    to

    Code:
     <add name=MyCustomProvider" type="MyCustomLibrary.Provider.CustomProvider, MyCustomLibrary" ...
    If I interpret the article correctly, it was looking for my custom provider in System.Web by default. Instead, you need to add the , MyCustomLibrary to tell it to look for your provider there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width