AvaloniaUI / AvaloniaVS

Visual Studio Extension for Avalonia
MIT License
412 stars 77 forks source link

Avalonia designer stuck with "Waiting for IntelliSense to finish initializing..." message when opening axaml-files during debugging #429

Open sinatrocious opened 7 months ago

sinatrocious commented 7 months ago

Describe the bug

If I run Avalonia desktop application first and then try to open axaml-file, then in opened Avalonia Xaml Editor tab I see the following message

Waiting for IntelliSense to finish initializing... You can continue working.

The message stays until I stop debugging.

Obviously I can't "continue working" to edit/view axaml-files. I need at least stop and then start debugging again.

What could possibly be the reason? It ocurrs (100% of times) in the big project.

To Reproduce

I am unable to reproduce it. With the new Avalonia Desktop project the axaml-files can be opened during debugging without problems.

AvaloniaVS plugin version

11.5

Avalonia version

11.0

Visual Studio version

17.7.7

Relevant log output

Nothing is added into "Avalonia Diagnostics" when opening axaml-file.

Additional context

No response

BinToss commented 3 months ago

AvaloniaVS, AvaloniaVSCode, and AvaloniaRider all rely on the CompletionEngine project in the AvaloniaVS repo. This assembly grabs the references plain text file in your workspace project's IntermediateOutput and loads...one of the Avalonia assemblies from either your IntermediateOutput or Debug Output. However, it cannot load the assembly if the assembly is already in use by another process and waits for the file handle to be or (on Windows) be opened/loaded without the FileOpenShare flag READ denied by any File handle. The classic "this file is open in another process" issue that can be prevented or even overriden (steal the handle from the kernel, duplicate it, and close all copied of the handle; as seen in Handles/Handles64 and System Informer). As implied earlier, a file can be opened by multiple processes so long as none of the file handles are opened without explicitly specifying the FILE_SHARE_READ shared-access permission. However, this Windows API is abstracted in .NET's LoadLibrary/DllImport implementation. The default way of loading NET assemblies does not make it easy to specify FILE_OPEN and FILE_SHARE flags.