Starts in:
1 DAY
9 HRS
31 MIN
39 SEC
Starts in:
1 D
9 H
31 M
39 S
Open Closed

ValidationErrors exception #2008


User avatar
0
agilmore created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include following:

  • ABP Framework version: v4.3.2
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I have this method in a MenuContributor class in my Blazor project: <br>

    private async Task<Guid> GetFirstProjectAsync(Guid sltnId)
    {
        Console.WriteLine($"SLTNID = {sltnId} ");

        var projectFilter = new GetProjectsInput
        {
            SltnId = new Guid("00000000-14ba-4f0f-8417-c2f312768aea")
        };

        projectFilter.MaxResultCount = PageSize;
        projectFilter.SkipCount = (CurrentPage - 1) * PageSize;
        projectFilter.Sorting = CurrentSorting;

        var result = await _projectsAppService.GetListAsync(projectFilter);  <--- THIS IS WHERE THE EXCEPTION HAPPENS

        if (result.Items.FirstOrDefault() != null)
        {
            return result.Items.FirstOrDefault().Id;
        }
        else
        {
            Guid defaultGuid =  default;
            return defaultGuid;
        }

    }

It returns the following exception:

>> mono_wasm_start_single_stepping 2 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: 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.Core.Lifetime.LifetimeScope.BeginLifetimeScope() at Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory.CreateScope() at Volo.Abp.Validation.ObjectValidator.GetErrors(Object validatingObject, String name, Boolean allowNull) at Volo.Abp.Validation.MethodInvocationValidator.AddMethodParameterValidationErrors(IAbpValidationResult context, ParameterInfo parameterInfo, Object parameterValue) at Volo.Abp.Validation.MethodInvocationValidator.AddMethodParameterValidationErrors(MethodInvocationValidationContext context) at Volo.Abp.Validation.MethodInvocationValidator.Validate(MethodInvocationValidationContext context) at Volo.Abp.Validation.ValidationInterceptor.Validate(IAbpMethodInvocation invocation) at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.<InterceptAsync>d__3`1[[Volo.Abp.Validation.ValidationInterceptor, Volo.Abp.Validation, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null],[Volo.Abp.Application.Dtos.PagedResultDto`1[[Datansa.App.Solution.ProjectDto, Datansa.App.Application.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Volo.Abp.Ddd.Application.Contracts, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Datansa.App.Blazor.Navigation.SolutionMenuContributor.GetFirstProjectAsync(Guid sltnId) in C:\Users\agilm\Documents\Repos\Datansa.App\src\Datansa.App.Blazor\Navigation\SolutionMenuContributor.cs:line 109 at Datansa.App.Blazor.Navigation.SolutionMenuContributor.ConfigureMainMenuAsync(MenuConfigurationContext context) in C:\Users\agilm\Documents\Repos\Datansa.App\src\Datansa.App.Blazor\Navigation\SolutionMenuContributor.cs:line 63 at Datansa.App.Blazor.Navigation.SolutionMenuContributor.ConfigureMenuAsync(MenuConfigurationContext context) in C:\Users\agilm\Documents\Repos\Datansa.App\src\Datansa.App.Blazor\Navigation\SolutionMenuContributor.cs:line 49 at Volo.Abp.UI.Navigation.MenuManager.GetAsync(String name) at Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout.Navigation.MainMenuProvider.GetMenuAsync() at Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout.MainHeader.MainHeader.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

However, I replicated the logic in a test method in my Application.Tests test project and the logic worked fine without exception.

Is it something to do with GUID?

This the class its trying to return:

public class ProjectDto : FullAuditedEntityDto<Guid> { public string Name { get; set; } public string Description { get; set; } public int DisplayOrder { get; set; } public List<ProjectConformDto> ProjectConforms { get; set; } }

Happy to provide the project if required.






10 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please share a simple project, thank you

    liming.ma@volosoft.com

  • User Avatar
    0
    agilmore created

    I've sent you a project. The class that has the issue is SolutionMenuContributor in the Blazor project. The test class/method is ProjectApplicationTests class GetListAsyncForSltn method in the Datansa.App.Application.Tests project.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Blazor is works fine. also GetListAsyncForSltn method.

  • User Avatar
    0
    agilmore created

    I had commented out the code in the SolutionMenuContributor , GetFirstProjectAsync method.

    Did you uncomment it before you tested. SolutionMenuContributor still doesn't work for me, although the test class does. This is the issue.

  • User Avatar
    0
    agilmore created

    You will also need to remove "return new Guid();" at the start of the GetFirstProjectAsync method.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    HI

    Can you make the above changes and resend the project ?

  • User Avatar
    0
    agilmore created

    I've sent you a link.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I have reproduced the problem and checking it.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer
    public async Task ConfigureMenuAsync(MenuConfigurationContext context)
    {
        //resolve Solution App Service dependency
        _solutionsAppService = context.ServiceProvider.GetRequiredService<ISolutionsAppService>();
    
        //resolve Project App Service dependency
        _projectsAppService = context.ServiceProvider.GetRequiredService<IProjectsAppService>();
    
        if (context.Menu.Name == StandardMenus.Main)
        {
            await ConfigureMainMenuAsync(context);
        }
    }
    
    public async Task ConfigureMenuAsync(MenuConfigurationContext context)
    {
        if (context.Menu.Name == StandardMenus.Main)
        {
            //resolve Solution App Service dependency
            _solutionsAppService = context.ServiceProvider.GetRequiredService<ISolutionsAppService>();
    
            //resolve Project App Service dependency
            _projectsAppService = context.ServiceProvider.GetRequiredService<IProjectsAppService>();
    
            await ConfigureMainMenuAsync(context);
        }
    }
    
  • User Avatar
    0
    agilmore created

    Thank you. I don't understand why, but this fixed the issue.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06