Can anyone help with this? I'm using the Install version of DNN 05.04.01 and every time I access RoleController or UserController, I get error message "Object reference not set to an instance of an object."
var container = new DotNetNuke.ComponentModel.SimpleContainer("UserTest");
DotNetNuke.ComponentModel.ComponentFactory.Container = container;
DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
DotNetNuke.Entities.Users.UserInfo ui = DotNetNuke.Entities.Users.UserController.GetUserById(0, UserID);
ui.Roles = (string[])rc.GetUserRoles(Contants.AMedPortal, UserID).ToArray(typeof(string));
if (!ui.IsInRole(rc.GetRole(roleID, 0).RoleName))
{
rc.AddUserRole(0, UserID, roleID, DateTime.Now, DotNetNuke.Common.Utilities.Null.NullDate);
}