c# – .NET MAUI project gets stuck on “Executing code cleanup” for minutes or indefinitely after adding Dependency Injection services


I’m working on a .NET MAUI project and I’m experiencing a severe performance/issue where Visual Studio gets stuck on “Executing code cleanup” for 2–10 minutes, or sometimes hangs forever, requiring me to kill Visual Studio via Task Manager.

When it happens

  1. After adding new maui page to Dependency Injection registration in MauiProgram.cs or any new service registration (e.g., builder.Services.AddSingleton();)

  2. On the very first project load when opening the solution

  3. Randomly during normal editing/building

During this time the status bar shows:

Code Cleanup in progress for C:\DEV\MAUI APPS\Baxo Inc\Applications\…

Executing code cleanup [progress bar that moves very slowly or freezes]

Saving Auto Recovery Information

CPU and memory usage are normal, but Visual Studio becomes completely unresponsive.

Errors/Warnings in Error List (always present)

Even when the project eventually loads or builds successfully, I always see these errors/warnings:

XLS0414 The type 'System.Object' was not found. Verify that you are not missing an assembly reference...

These XLS0414 errors appear on almost every XAML file (ContentPage, etc.)

Code clean up image

enter image description here

What I’ve already tried

  1. Clean + Rebuild solution

  2. Delete .vs, bin, obj folders

  3. Restart Visual Studio / computer

  4. Repair Visual Studio

  5. Disable IntelliCode / IntelliSense for XAML

  6. Update to latest Visual Studio

  7. Clear NuGet cache

None of these solve the hanging “code cleanup” issue.

Question

Has anyone else experienced Visual Studio getting stuck indefinitely on “Executing code cleanup” in a .NET MAUI project after adding DI services or on project load? The XLS0414 “System.Object was not found” errors seem related, but the project actually builds and runs fine once the freeze ends.

Is this a known bug? Is there a permanent workaround or fix?

Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *