Object reference not set to an instance of an object

Discussion in 'ASP .Net Security' started by Nick, Nov 2, 2006.

  1. Nick

    Nick Guest

    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
     
    Nick, Nov 2, 2006
    #1
    1. Advertising

  2. Have you implemented all the abstract methods?

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

    Set a breakpoint and see where it fails.



    ---
    Dominick Baier, DevelopMentor
    http://www.leastprivilege.com

    > 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.
    > Nic
     
    Dominick Baier, Nov 3, 2006
    #2
    1. Advertising

  3. Nick

    Nick Guest

    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.

    Dominick Baier wrote:
    > Have you implemented all the abstract methods?
    >
    > can you manually call Membership.ValidateUser() (e.g.) ?
    >
    > Set a breakpoint and see where it fails.
    >
    >
    >
    > ---
    > Dominick Baier, DevelopMentor
    > http://www.leastprivilege.com
    >
     
    Nick, Nov 3, 2006
    #3
  4. so - set a breakpoint in GetAllUsers and see what happens !?

    ---
    Dominick Baier, DevelopMentor
    http://www.leastprivilege.com

    > GetAllUsers
    >
     
    Dominick Baier, Nov 3, 2006
    #4
  5. Nick

    Nick Guest

    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


    Nick wrote:
    > 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
     
    Nick, Nov 3, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parthiv Joshi
    Replies:
    2
    Views:
    718
    Kalyan
    Jul 2, 2004
  2. Suresh Kojhani
    Replies:
    1
    Views:
    2,428
    Anushi
    Jul 29, 2004
  3. Chris Fink
    Replies:
    2
    Views:
    4,139
    David Waz...
    Jul 3, 2003
  4. yysiow
    Replies:
    1
    Views:
    461
    Kevin Spencer
    Jul 12, 2003
  5. Replies:
    1
    Views:
    516
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page