Skip to content

Error System.MissingMethodException thrown when trying to see the query plan of an IQueryable variable #28

Closed

Description

@jmoralesv

Hello,
I was trying to use the extension with VS 2022, latest version 17.9.1, but I got this error:

Cannot evaluate expression since the function evaluation requires all threads to run.

image

Then I checked the logs in the Output window and found this:

System.MissingMethodException thrown when loading the VisualizerAssemblyLoadContext. Message: Cannot dynamically create an instance of type 'Microsoft.VisualStudio.NetCoreAssemblyResolution.VisualizerAssemblyLoadContext'. Reason: No parameterless constructor defined.

My IQueryable variable is something not too fancy, I'm working in a private code base so I can't post the actual tables, but it resembles something like this:

var postsQuery = dbContext.Posts
    .Where(x => x.DeletedDate == null && x.Blog.DeletedDate == null)
    .Where(x => x.Title == title && x.Blog.Name == blogName);

var posts = await postsQuery.ToListAsync();

The error happens when trying to see the query plan for the postsQuery variable.

My application is based on EF Core 8, .NET 8, Windows 11 Pro 23H2

What could be wrong?

Activity

  1. Giorgi commented on Feb 27, 2024

    @Giorgi
    Owner

    It looks like an internal VS issue because I don't instantiate VisualizerAssemblyLoadContext anywhere in my code. When I search for VisualizerAssemblyLoadContext on GitHub the only result is this issue. I suggest you report the issue and link to this issue in case they want to reach out to me.

  2. jmoralesv commented on Feb 29, 2024

    @jmoralesv
    Author

    Hi @Giorgi I have tested with a different project, a simpler one, and with the VS Enterprise edition I also have installed, and it worked this time. This is how it looks like:

    image

    No problem sharing this query, it's from a side project not in actual and real development 😄

    After testing it in the Enterprise edition, I opened the same solution in the VS Pro edition, and it worked this time as well.

    So, this could be related to either the VS edition I was using EFCore.Visualizer with (maybe I have to use it in both editions so the extension gets "activated" in both), or related to the source code, but I highly doubt it could be related to the code.

    All these projects are .NET 8 based, using EF Core 8 and SQL Server, with the latest updates. The only difference is the type of project. The one from the original issue was a console app, whereas the one I tested with the Enterprise edition is an MVC web app.

    I'll test with other projects (work and side projects) to check if EFCore.Visualizer works correctly.

  3. jmoralesv commented on Mar 9, 2024

    @jmoralesv
    Author

    @Giorgi as a conclusion for this issue, I think the visualizer sometimes works and sometimes doesn't depending on the dependencies and complexities the projects might have.

    For example, when testing with simpler web and console projects, the visualizer works as expected. However, in more complex ones, with dependencies on Azure, Redis, and third-party libraries and other services, those bother the debugger somehow and prevent the visualizer from working.

    The only constant thing is the System.MissingMethodException error which always appears in the Debug output window. I have just reported that error to the Developer Community site, as that is the only constant error appearing during my tests: https://developercommunity.visualstudio.com/t/SystemMissingMethodException-thrown-whe/10612094

    I think we can close this issue as not reproducible or not fixed, it is hard to reproduce. If I notice a different behavior in the future, I would add a new comment here.

  4. Giorgi commented on Mar 25, 2024

    @Giorgi
    Owner

    After a long investigation by @jmoralesv, it turned out that the "Cannot evaluate expression since the function evaluation requires all threads to run." error was caused by Application Insights. It profiles database queries and is probably trying to send the data on a background thread causing the above error.

    Thank you again Jorge for spending so much time to find the root cause.

  5. jmoralesv commented on Mar 25, 2024

    @jmoralesv
    Author

    @Giorgi thanks to you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions