Object reference not set to an instance of an object

N

Nick

I have created a custom membership provider based on the Microsoft
example. Here is the beginning of the class:

namespace AspNet.Membership {
public sealed class MySQLMembershipProvider : MembershipProvider {

and here is web.config file:

32 <membership defaultProvider="MySQLMembershipProvider">
33 <providers>
34 <clear/>
35 <add name="MySQLMembershipProvider"
36 connectionStringName="MySQLConnectionString"
37 type="AspNet.Membership.MySQLMembershipProvider"
38 applicationName="fleetsweep"/>
39 </providers>
40 </membership>

When I try to access the web.config file from Web Site Administration
Tool, I get the following error:

There is a problem with your selected data store. This can be caused by
an invalid server name or credentials, or by insufficient permission.
It can also be caused by the role manager feature not being enabled.
Click the button below to be redirected to a page where you can choose
a new data store.

The following message may help in diagnosing the problem: Object
reference not set to an instance of an object.
(C:\Inetpub\wwwroot\fleetsweep\web.config line 37)

I am able to instantiate the class and use it.

thanks for your help.
Nick
 
D

Dominick Baier

Have you implemented all the abstract methods?

can you manually call Membership.ValidateUser() (e.g.) ?

Set a breakpoint and see where it fails.
 
N

Nick

Yes, all the abstract methods have been implemented.

I have traced the error to this line:

MembershipUserCollection users = (MembershipUserCollection)
CallWebAdminHelperMethod(true, "GetAllUsers",new object[] {0,
Int32.MaxValue, total}, new Type[]
{typeof(int),typeof(int),Type.GetType("System.Int32&")});

in security.aspx file in the

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\Security
folder.

CallWebAdminHelperMethod in WebAdminPage.cs calls an "Invoke" method
which fails with the error I pasted earlier. This is the line that
generates the error:

object[] returnArrayObj = (object[]) method.Invoke(tempObject,
newParameters);
From my web application, I can manually create a user with
Membership.CreateUser and it works fine.
 
N

Nick

Ok, the nightmare is over.

I had gotten the MySQL implementation of the MySQLMembershipProvider
from a "well-known" code repository recommended by MS people. One of
the 2 classes had this line in a most of the methods:

System.Web.HttpContext.Current.Trace.Warn("MySQLMembershipProvider.ResetPassword");

The Web Site Administration Tool did not like that and generated the
error. It has only taken me 24 hours to figure that out, I'm pretty
sure that I can get the grey hair out with "Just For Men" hair color.
Nothing like a little stress to spice up your life.

n
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top