|
-
Feb 8th, 2010, 12:17 PM
#1
Thread Starter
Addicted Member
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
-
Oct 12th, 2010, 01:57 AM
#2
New Member
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
-
Jul 21st, 2011, 12:02 PM
#3
New Member
Re: Using Custom Membership Provider in WinForms
hello, still no one knows?
Regards...SiViN
-
Sep 9th, 2011, 06:31 AM
#4
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|