Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lasse 1 post 21 karma points
    Jan 23, 2013 @ 10:35
    Lasse
    0

    Membership.CreateUser = Object reference not set to an instance of an objet

    Hi.

    Im new to umbraco and im trying to make new members in umbraco thorugh a WCF service.

    In umbraco i have made a Membertype called "Patient" with custom properties.

    When im trying the following line in my c# code for the WCF service: 

    MembershipUser newUser = Membership.CreateUser("username", "password", "email", "question", "answer", true, out status); 

    I get an exception with "Object reference not set to an instance of an object. 

    Stacktrace of exception:
    at umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(String loginName)\r\n  
    at umbraco.providers.members.UmbracoMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)\r\n  
    at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)\r\n  
    at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, MembershipCreateStatus& status)\r\n  
    at PatientNetService.PatientNetService.AddUserToUmbraco(Patient patientObj)" string

    (The strange thing here is if i make an member in Umbraco, i can from my code get that member and override properties. I can also use CreateUser on that specific username and im then told that the username is already there.
    Furthermore, i dont understand why it is calling GetMemberFromLoginName instead of createUser!)

    I read multiple post regarding this issue and i tried even to use the deprecated Member.MakeNew, but this result in same error. 

    Also read the the webconfig needs to be modified and it looks like this : (the important thing here is defaultMemberTypeAlias, as i understand it).

        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">

          <providers>

            <clear/>

            <add name="UmbracoMembershipProvider" 

                 type="umbraco.providers.members.UmbracoMembershipProvider" 

                 enablePasswordRetrieval="false" 

                 enablePasswordReset="false" 

                 requiresQuestionAndAnswer="false" 

                 defaultMemberTypeAlias="Patient" 

                 passwordFormat="Hashed"/>

            <add name="UsersMembershipProvider"

                 type="umbraco.providers.UsersMembershipProvider"

                 enablePasswordRetrieval="false" 

                 enablePasswordReset="false"

                 requiresQuestionAndAnswer="false" 

                 passwordFormat="Hashed"/>

          </providers>
        </membership>

    Im surprised why this is so hard to do, and im running out of ideas now so im trying to get some help here :)

    Hope you can help!

Please Sign in or register to post replies

Write your reply to:

Draft