Try our conversational search powered by Generative AI!

Error when creating new user

Vote:
 

Environment:

  • EPiServer CMS 6 R2
  • EPiServer Relate 2 R2 on top of above

Issue:

  • Trying to add user programmatically but fails and get this error:    "Exception message: Value cannot be null.
    Parameter name: value"

 

This happens when I try to add user or try geta guid.

----------------------------------------------------------------------------------------------------------------------------

IUser newUser = CommunitySystem.CurrentContext.DefaultSecurity.GetUserByUserName(EmailBox.Text.Trim(',')) as IUser;

                if (newUser == null)
                {
                    DatabaseHandler.Instance.RunInTransaction(delegate
                    {
                        newUser = (IUser)CommunitySystem.CurrentContext.DefaultSecurity.NewUser;
                        newUser.UserName = UserNameBox.Text.Trim(',');
                        newUser.EMail = EmailBox.Text.Trim(',');
                        newUser.Password = PasswordBox.Text.Trim(',');
                        newUser.GivenName = FirstNameBox.Text.Trim(',');
                        newUser.SurName = LastNameBox.Text.Trim(',');
                        newUser.Alias = String.Format("{0} {1}", newUser.GivenName, newUser.SurName);
                        newUser.Culture = System.Globalization.CultureInfo.CurrentUICulture;
                  
                        newUser.BirthDate = new DateTime(2008, 3, 9, 16, 5, 7, 123);

                        activationGuid = (Guid)CommunitySystem.CurrentContext.DefaultSecurity.AddUserToActivate(newUser); // Error!******
                        //newUser = (IUser)CommunitySystem.CurrentContext.DefaultSecurity.AddUser(newUser); // Error!*******
                                          
                    });
                }              

 

 

 

#50793
May 12, 2011 15:34
Vote:
 

Please share the stack trace, it helps pinpoint generic error messages such as this one.

#51639
Jun 18, 2011 1:59
Vote:
 

If you debug that and look at all your textbox values are they filled?

 

Or what do the properties on newUser look like before calling AddUser?

#51977
Jun 30, 2011 17:26
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.