Произошла ошибка при удалении пользователя в EpiServer - ArgumentNullException: тип не может быть пустым - PullRequest
0 голосов
/ 05 декабря 2018

Я использовал,

CommunitySystem.CurrentContext.DefaultSecurity.RemoveUser(IUser user);

Чтобы удалить пользователя (Так же, как ответ, опубликованный в в этом выпуске ).

Однако это работает нормально.Но для одного пользователя это выдает ошибку.Выдает исключение из RemoveUser(IUser user).

Подробности исключения приведены здесь, как показано ниже,

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)

Я попытался извлечь Type и Имя типа, и оно работало нормально.

IUser user = getUser(id);
Type type = user.AccessRightsType;
string typeName = new EPiServer.Data.Entity.Internal.EntityTypeResolver().GetTypeName(type, true); // Not null. This value is as same as on other users

Обновление: я декомпилировал EPiServer.Common.ImplementationModule, и это то, что есть у HandleCommentAddUpdateRemove(..).

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);
}

Что вызывает это?

Кажетсякак и в приведенном ниже коде, возвращается «Null»

commentedEntity.get_Type();

Любой способ удалить этого пользователя?

Дополнительная информация:

EPiServer.CommonFramework version=9.0.1
EPiServer.CMS.Core version=11.11.0
EPiServer.Community version=9.0.0
...