Copied to clipboard

Flag this post as spam?

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


  • Arthur 2 posts 22 karma points
    Jan 13, 2010 @ 22:50
    Arthur
    0

    Member.GetMemberFromEmail threw a null reference exception

     

    I am trying to create new members using the Umbraco API. Here is my code.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    if (Member.GetMemberFromEmail("[email protected]") == null

    )

    {

     

    MemberType memberType = MemberType.GetByAlias("AdminType");

    MemberGroup mg = MemberGroup.GetByName("AdminGroup");

     

    Member newMember = Member.MakeNew("Email", memberType, new umbraco.BusinessLogic.User(0));

    newMember.Email = "

    [email protected]";

     

    newMember.Password =

    "Password";

    newMember.LoginName =

    [email protected];

    newMember.getProperty(

    "Address").Value = "Address";

    //set value of property with alias address

    newMember.getProperty(

    "Phone").Value = "Phone";

    //set value of property with alias city

     

    //Generate member Xml Cache

     

    //newMember.XmlGenerate(new System.Xml.XmlDocument());

     

    newMember.AddGroup(mg.Id);

    newMember.Save();

     

    }

     

    else

    {

     

    //member exists

    }

    The above code is throwing an exception on the first line (Member.GetMemberFromEmail([email protected]) )

    I do know that  Member.GetMemberFromEmail will return null if the email address doesn't exists. My problem is, the exception is being thrown from inside the GetmemberFromEmail method .

    (When i commented that line and ran the program , the application threw the null reference exception from the next line MemberType memberType = MemberType.GetByAlias("AdminType"); )

    Does anyone have any insight on the cause of this issue ?

    I would appreciate any guidance to solve this problem.

    Thanks

     

  • Arthur 2 posts 22 karma points
    Jan 14, 2010 @ 15:44
    Arthur
    0

    Figured it out guys.

    The issue is caused by  missing information (required by umbraco API)  in the web.config file .

    If you ever encounter the same problem , Please make sure to check for all the umbraco specific information in the web.config file before trying other options.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft