Developer forum

Forum » Development » Error when trying to create a new User c#

Error when trying to create a new User c#

Jonas Mersholm
Reply

Doing the following:

 

            Dynamicweb.Modules.UserManagement.User F = new Dynamicweb.Modules.UserManagement.User();
            F.Name      = name;
            F.Email = F.UserName  = email;
            F.Password = password;
            F.Zip = zip;
            F.Address = adress;
            F.Active = true;
            F.AllowBackend = true;
            F.Save();

 

 

Gives me this error message:

 

[NullReferenceException: Object reference not set to an instance of an object.]
   Dynamicweb.Modules.UserManagement.User.get_Current(PagePermissionLevels level) +423
   Dynamicweb.Modules.UserManagement.AuditUserInfo.NotifyUserSaving(Boolean IsNewUser, Boolean FromImport) +62
   Dynamicweb.Modules.UserManagement.User.Save() +155

 

 

Any idea on, why this error happens? 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Where are you running this code?

 

Also, the erorr messages talks about PagePermissions. Does the User object have a property for that that you may need to set to some instance?

Imar

 
Jonas Mersholm
Reply
This post has been marked as an answer

Just now figured it out. I'm working in a ASHX handler. Creating a user required session handling ( dont ask me why ), so when setting the IRequiresSessionState interface as available fixed the problem.

 

Thanks for your reply.

Votes for this answer: 1

 

You must be logged in to post in the forum