Compilation error when checking existence of BusinessPackDataSet item

I need to check existence of item in my BusinessPackDataSet on front end. I do this using this crazy expression

IncludeInPage="{value: _root.VykonsOverviewViewModel.MedicalProcedures.Items.ToList().Any(x => x.IdCvykon == CVykonId.MicrofluidicSpermSorting) == false}"

This randomly throws compilation Exception

Could not find instance member ToList on type System.Collections.Generic.IList<Vykon.Domain.QueryService.Patient.ReadModels.VykonRm>.

The solution is to rebuild whole project. FE compilation does not seem to be deterministic at this point. Do you have any idea what is wrong here? Or I am expecting too much from IList in GridViewDataSet?

FYI: I used expression without .ToList() in the past with similar error and I think the exception occurred more often.

DotVVM 4.2.7
DotVVM.BusinessPack 4.2.0
config.Markup.ViewCompilation.Mode = ViewCompilationMode.AfterApplicationStart;

Thanks for help!

Thanks for letting us know, this does not sound good. We have got a report of non-deterministic extension method resolution previously, but were unable to pin down the issue :confused: Your expression should definitely work, we have similar ones in our tests which do work fine (I tried over 2M restarts…).

Could you please share bit more information about your deployment? (mainly OS, .NET version) Does it occur only in prod/development or both?

Anyway, the issue seems to be in our extension methods implementation, so you can probably workaround it by calling the method as static (i.e. Enumerable.Any(Enumerable.ToList(_root.VykonsOverviewViewModel.MedicalProcedures), x => x.IdCvykon == CVykonId.MicrofluidicSpermSorting)).

I don’t want to write misleading information, so I will inspect it more for a while. I was unable to reproduce the issue in separate DEMO project. I will post my results.

Thank you! I totally believe that this bug exists as I have got similar reports. It would be great, if you would be able to figure out what is the difference between the broken and a working application

I was checking this for a while. The issue still occurs. I am experiencing this for a long time. It could be 1 year. I am mentioning only current versions.

DEV environment:
When I rebuild the solution and check compilation page there is almost all the time one of these errors.

  • DotVVM libraries 4.3
  • dotnet 8.0.400
  • Windows 11, 22H2, Build 22621.4169
  • latest Visual studio
  • config.Markup.ViewCompilation.Mode = ViewCompilationMode.AfterApplicationStart;

Build server:
We have Github pipline task to verify compilation. We had to set up retry logic in case the task fails for the first time:/ We used selenium test hitting compilation URL in the past.

[Fact]
public async Task CompileAllViews_Succeeds()
{
    var webApplicationFactory = new CustomWebApplicationFactory<Startup>();
    var dotvvmViewCompilationService = webApplicationFactory.Services.GetRequiredService<IDotvvmViewCompilationService>();

    var wasCompilationSuccessful = await dotvvmViewCompilationService.CompileAll();

    wasCompilationSuccessful.Should().BeTrue();
}
  • DotVVM 4.2 (4.3 so far without error, but I am testing only for the first week)
  • dotnet 8.0.400
  • Ubuntu 22.04.4 LTS
  • config.Markup.ViewCompilation.Mode = ViewCompilationMode.AfterApplicationStart;

Production:
I have a feeling that there are less reports about this problem during last months. Earlier before it was very common…

  • Dotvvm libraries 4.2 (4.3 not yet deployed)
  • Docker 20.10.12 - base image mcr.microsoft.com/dotnet/aspnet:8.0.8
  • Ubuntu 20.04.4 LTS
  • config.Markup.ViewCompilation.Mode = ViewCompilationMode.AfterApplicationStart;

I am struggling to find common denominator. Right now I will change compilation mode in all environments and check if something was changed. If you need some more data or any other help, just let me know.

Hi! Thanks a lot for providing more details. Unfortunately, I’m not sure I can reproduce it with this, as I tried it in a similar configuration and it apparently isn’t platform dependent. I think there must be something with the project configuration.

I’m deducting that

  • It’s significantly more common in your dev environment than in production
  • 4.3 maybe helped, but definitely didn’t solve it

If you can easily replicate the issue, could you maybe try to compare the contents of the ExtensionMethodsCache.methodsCache field? If an entire assembly is missing, or only specific namespace, or if the problem is elsewhere. This is a piece of code which dumps its contents: Test to diagnose extension method load instability by exyi · Pull Request #1780 · riganti/dotvvm · GitHub. Let me know if you want some assistance with this.


By the way, DotVVM integrates with the Asp.Net Core healthcheck and it should report its state as “Degraded”, if at least one page failed to compile. This might simplify your retry logic (or if someone else finds this discussion later)