Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Error occurred when removing the user in EpiServer - ArgumentNullException: The type cannot be null

Vote:
 
I have used,
CommunitySystem.CurrentContext.DefaultSecurity.RemoveUser(IUser user);

To remove user (Just as the answer posted in this issue).

However, this works fine. But for one user it gives an error. The exception throws from the RemoveUser(IUser user).

The exception details are here as below,

System.ArgumentNullException: The type cannot be null. Parameter name: type 
at EPiServer.Data.Entity.Internal.EntityTypeResolver.GetTypeName(Type type, Boolean ignoreOverrideAttribute) 
at EPiServer.Common.ImplementationModule.HandleCommentAddUpdateRemove(IComment comment, SupportedOperations operation) 
at EPiServer.Common.Comments.CommentHandler.OnCommentUpdated(IComment comment) 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass32_0.b__0() 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.b__0() 
at EPiServer.Common.Comments.CommentHandler.UpdateComment(IComment comment) 
at EPiServer.Common.Data.FrameworkFactoryBase.CascadeUpdateStatus(IEntityStatus entity, ICollection`1 children) 
at EPiServer.Common.Data.CommentFactory.CascadeAuthorStatus(IAuthor author) 
at EPiServer.Common.AuthorEventHandler.Invoke(EntityEventArgs args) 
at EPiServer.Common.AuthorHandler.OnAuthorUpdated(IAuthor author) 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass32_0.b__0() 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.b__0() 
at EPiServer.Common.AuthorHandler.UpdateAuthor(IAuthor author) 
at EPiServer.Common.Data.FrameworkFactoryBase.CascadeUpdateStatus(IEntityStatus entity, ICollection`1 children) 
at EPiServer.Common.Security.Data.SecurityFactory.<>c__DisplayClass57_0.b__0() 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass32_0.b__0() 
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.b__0() 
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method) 
at EPiServer.Common.Security.SecurityHandler.RemoveUser(IUser user)

I have decompiled the 'EPiServer.Common.ImplementationModule' and this is what the 'HandleCommentAddUpdateRemove(..)' has.

private static void HandleCommentAddUpdateRemove(IComment comment, SupportedOperations operation) {
    EntityReference commentedEntity = comment.CommentedEntity;
    IComment comment2 = null;
    CommentEventData commentEventData;
    if ((int) operation == 4) {
        comment2 = (IComment) comment.get_Master();
        if (comment2 == null || comment2.Status == comment.Status) {
            return;
        }
        commentedEntity = comment2.CommentedEntity;
        commentEventData = new CommentEventData(IEntityTypeResolverExtensions.GetTypeName(ServiceLocator.get_Current().GetInstance < IEntityTypeResolver > (), commentedEntity.get_Type()), commentedEntity.get_ID(), comment2.Status, -1);
        m_commentEvent.Raise(m_commentId, (object) commentEventData);
    }
    commentEventData = new CommentEventData(IEntityTypeResolverExtensions.GetTypeName(ServiceLocator.get_Current().GetInstance < IEntityTypeResolver > (), commentedEntity.get_Type()), commentedEntity.get_ID(), comment.Status, ((int) operation != 8) ? 1 : (-1));
    m_commentEvent.Raise(m_commentId, (object) commentEventData);
}

What causes this to happen ?

It seems like the below code returns 'Null'

commentedEntity.get_Type();

Any way to delete this user?

Additional info:

EPiServer.CommonFramework version=9.0.1
EPiServer.CMS.Core version=11.11.0
EPiServer.Community version=9.0.0
#203974
Edited, May 15, 2019 7:14
Vote:
 

Any update on this ?

#204230
May 23, 2019 7:02
* 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.