Hi,
I'm using ABP 0.83 (I think) with asp net zero and I'm getting an error when I'm trying to edit a user. The error is thrown at the UserAppService.cs: await UserManager.SetRoles(user, input.AssignedRoleNames); It cannot save the roles and the following error occurs:
Value cannot be null.\r\nParameter name: source
Attached are the properties of the user, and the assignedRoleNames are also filled properly (at least that is what it looks like)
Any idea what's going wrong and how to solve this?
9 Answer(s)
-
0
Can you also share stacktrace for this exception ?
-
0
Hi,
This is everything of the stacktrace I can get
StackTrace = " at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)\r\n at Abp.Authorization.Users.AbpUserManager
3.<SetRoles>d__7e.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.Compiler...Thanks
-
0
I think the problem is, Roles collection of user is null. Can you share your dto you used when updating user ?
-
0
Hi,
I can't get the dto because it's somewhere in the boilerplate dll's, I haven't touched those. So when this is executed: var user = await UserManager.FindByIdAsync(input.User.Id.Value); the roles in user are indeed empty, but I can't have a good look at the FindByIdAsync method.
Thanks
-
0
Can you share user update method of UserAppService including method name and method input ?
-
0
Yes, here it is!
[AbpAuthorize(AppPermissions.Pages_Administration_Users_Edit)] protected virtual async Task UpdateUserAsync(CreateOrUpdateUserInput input) { Debug.Assert(input.User.Id != null, "input.User.Id should be set.");
var user = await UserManager.FindByIdAsync(input.User.Id.Value); //Update user properties input.User.MapTo(user); //Passwords is not mapped (see mapping configuration) if (!input.User.Password.IsNullOrEmpty()) { CheckErrors(await UserManager.ChangePasswordAsync(user, input.User.Password)); } CheckErrors(await UserManager.UpdateAsync(user)); try { //Update roles CheckErrors(await UserManager.SetRoles(user, input.AssignedRoleNames)); await UserManager.SetRoles(user, input.AssignedRoleNames); if (input.SendActivationEmail) { user.SetNewEmailConfirmationCode(); await _userEmailer.SendEmailActivationLinkAsync(user, input.User.Password); } }catch(Exception ex) { throw ex.InnerException; } }
Btw, the CheckErrors method for update roles is the first line that throws the error
-
0
I couldn't reproduce your scenario. Roles collection is either an empty array or filled with items, it was never null in my tests.
Can you share your project and database to simulate same scenario if it is possible.
You can send it privately to our info email address.
-
0
Hi, I facing same the problem, is it resolved?
-
0
Hi,
Can you check that in your AppService, the Roles property of your input is null or an empty list ?