Activities of "zhongfang"

Happend again。

thank you! all my questions have been resolved.

The questions has changed, now there are 2 as below

1. ExtraPropertity only Saved for the first one

2. Only return users of current tenant.

I want to get all users in the database, so I disable the DataFilter. But it seems that the IMultiTenant has not been disabled. I only get the users in the current tenant.

using (this.DataFilter.Disable<IMultiTenant>())
            {
                users = await userRepository.GetListAsync();
            }

Thank you!

replace Repository with Manager

public class SerialNumberMoreAppService : AccountAppService, ISerialNumberMoreAppService
    {
        public virtual async Task<long> GetNextValueAsync()
        {
            SerialNumberManager repository = this.LazyServiceProvider.LazyGetRequiredService<SerialNumberManager>();

            var netSerial = await repository.CreateAsync("");
            await UnitOfWorkManager.Current.SaveChangesAsync();

            return netSerial.Id;
        }
    }

Can get increased id successfully, but ...

but user.SetProperty only valid for the first user?

I want to reset propertiy for all users.

foreach (var user in users)
      {
                var number = await serialNumberMoreAppService.GetNextValueAsync();
                user.SetProperty(ChangeUserConsts.NumberIdPropertityName, number);
                await UnitOfWorkManager.Current.SaveChangesAsync();
      }
  • ABP Framework version: v5.2.2
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
[21:15:01 ERR] An exception occurred in the database while saving changes for context type 'Yee.Change.Account.EntityFrameworkCore.AccountDbContext'.
System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
   at Microsoft.EntityFrameworkCore.Infrastructure.Internal.ConcurrencyDetector.EnterCriticalSection()
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
   at Microsoft.EntityFrameworkCore.Infrastructure.Internal.ConcurrencyDetector.EnterCriticalSection()
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Volo.Abp.Uow.UnitOfWork.SaveChangesAsync(CancellationToken cancellationToken)
   at Volo.Abp.Uow.UnitOfWork.CompleteAsync(CancellationToken cancellationToken)
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
[21:15:01 WRN] Unhandled exception rendering component: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
   at BootstrapBlazor.Components.Button.<OnInitialized>b__16_0()
   at BootstrapBlazor.Components.BootstrapComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at BootstrapBlazor.Components.BootstrapComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
[21:15:01 ERR] Unhandled exception in circuit 'ihxcWkmkdBt_4qWN9ok7xkBVHfMORbNtZ--JQmxpUWA'.
System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
   at BootstrapBlazor.Components.Button.<OnInitialized>b__16_0()
   at BootstrapBlazor.Components.BootstrapComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at BootstrapBlazor.Components.BootstrapComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
[21:15:01 INF] Executed endpoint '/_blazor'
[21:15:01 INF] Request finished HTTP/1.1 GET https://localhost:44313/_blazor?id=x8MY4ZFA5575PWSz5kjBsQ - - - 101 - - 8460.8296ms
[21:15:01 WRN] Could not save the audit log object:
AUDIT LOG: [---: -------] Yee.Change.Account.SerialNumbers.SerialNumberMoreAppService.GetNextValueAsync
- UserName - UserId                 : admin - 2b080ea8-6fdc-5e40-685e-39fe0f560247
- ClientIpAddress        : 127.0.0.1
- ExecutionDuration      : 733
- Actions:
  - Yee.Change.Account.SerialNumbers.SerialNumberMoreAppService.GetNextValueAsync (729 ms.)
    {}
- Exceptions:
  - Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'AccountDbContext'.
    System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'AccountDbContext'.
   at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
   at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_ChangeTracker()
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.InsertAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Yee.Change.Account.SerialNumbers.SerialNumberMoreAppService.GetNextValueAsync()
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope)
   at Volo.Abp.Auditing.AuditingInterceptor.ProcessWithNewAuditingScopeAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, ICurrentUser currentUser, IAuditingManager auditingManager, IAuditingHelper auditingHelper, IUnitOfWorkManager unitOfWorkManager)

[21:15:01 ERR] Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.
   at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag)
   at Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory.CreateScope()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Abp.AuditLogging.AuditingStore.SaveLogAsync(AuditLogInfo auditInfo)
   at Volo.Abp.AuditLogging.AuditingStore.SaveAsync(AuditLogInfo auditInfo)
  • Steps to reproduce the issue:"
  • I have a module . and provide a function as below. Only return a serial nuber. because the primary key is big intergal.
namespace Yee.Change.Account.SerialNumbers
{
    using System;
    using System.Text;
    using System.Threading.Tasks;
    using System.Collections.Generic;

    public class SerialNumberMoreAppService : AccountAppService, ISerialNumberMoreAppService
    {
        public virtual async Task<long> GetNextValueAsync()
        {
            ISerialNumberRepository repository = this.LazyServiceProvider.LazyGetRequiredService<ISerialNumberRepository>();

            var netSerial = await repository.InsertAsync(new SerialNumber(), autoSave: true);
            await UnitOfWorkManager.Current.SaveChangesAsync();

            return netSerial.Id;
        }
    }
}
  • In another module, I want to call above function to get the serial number. but failed , and throw the exception I mentioned.
namespace Yee.Change.AdminBlazorUI.TempTasks
{
    using Volo.Abp.Data;
    using Volo.Abp.Users;
    using Volo.Abp.MultiTenancy;
    using Yee.Change.Account.SerialNumbers;

    public class UserNumberIdsResetAppService : ApplicationService, IUserNumberIdsResetAppService
    {
        public async Task Reset()
        {
            IIdentityUserRepository userRepository = this.LazyServiceProvider.LazyGetRequiredService<IIdentityUserRepository>();
            ISerialNumberMoreAppService serialNumberMoreAppService = this.LazyServiceProvider.LazyGetRequiredService<ISerialNumberMoreAppService>();

            List<IdentityUser> users;
            using (this.DataFilter.Disable<IMultiTenant>())
            {
                users = await userRepository.GetListAsync(userName: "10093@ok.no");
            }

            users.ForEach(async u =>
            {
                await this.UpdateUser(serialNumberMoreAppService, u);
            });
        }

        async Task UpdateUser(ISerialNumberMoreAppService serialNumberMoreAppService, IdentityUser user)
        {
            long number = await serialNumberMoreAppService.GetNextValueAsync();
            user.SetProperty("NumberId", number);
        }
    }
}

Oh, It is caused by Automapper. My custome module missed settings. After I resolve my own Automapper configuration. program starte successfully.

abp install-libs

  • In visual studio
  • Right click on the solution
  • select 'Open in Terminal'
  • abp install-libs
  • return
  • ABP Framework version: v5.2.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • no error log in Logs.txt, the last log line is 2022-04-15 09:59:19.404 +08:00 [INF] Starting IdentityServer4 version 4.1.2+997a6cdd643e46cd5762b710c4ddc43574cbec2e
  • stop here in Visual Studio 2022
  • the full text in above picture is
Autofac.Core.DependencyResolutionException:“An exception was thrown while activating Volo.Abp.IdentityServer.Grants.PersistedGrantStore -> Volo.Abp.ObjectMapping.DefaultObjectMapper`1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=5.2.0.0, Culture=neutral, PublicKeyToken=null]] -> Volo.Abp.AutoMapper.AutoMapperAutoObjectMappingProvider`1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=5.2.0.0, Culture=neutral, PublicKeyToken=null]] -> λ:Volo.Abp.AutoMapper.IMapperAccessor -> λ:Volo.Abp.AutoMapper.MapperAccessor.”
  • Steps to reproduce the issue:"
  • I have upgrade to ABP 5.2.0 many day ago, and everything is ok
  • Now I can not start the project with DEBUG under Visual Studio 2022(not preview version)

Thanks! After I run the command abp install-libs on solution folder, the error has been fixed.

Oh, after I renamed the file, add -s. I can run the application now.

Showing 81 to 90 of 160 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 20, 2024, 08:30