WPF & Winforms with Blazor app leak 2 file system handles every time app.css is saved
See original GitHub issueSteps to reproduce:
- Create a WPF or Winforms app and enable Blazor as described here Build a Windows Presentation Foundation (WPF) Blazor app | Microsoft Learn
- Run the application
- In VS, save wwwroot\css\app.css
- Run the sys internals tool handle.exe on that file path and you will see the number of open handles increase by 2.
- Save it again and run handle.exe and 2 more open handles are charged to the app.
These open handles seem to cause some issues with the way VS saves the file. It saves correctly but it seems to generate 2 save events, so we process the file change twice.
Here’s a proc mon trace showing this. Note the 3 calls o CreateFile but only one CloseFile.
11:47:22.4461876 AM WpfApp1.exe 23308 CreateFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:47:22.4462182 AM WpfApp1.exe 23308 QueryNetworkOpenInformationFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS CreationTime: 5/9/2022 9:56:21 AM, LastAccessTime: 10/27/2022 11:47:22 AM, LastWriteTime: 10/27/2022 11:47:22 AM, ChangeTime: 10/27/2022 11:47:22 AM, AllocationSize: 4096, EndOfFile: 693, FileAttributes: A
11:47:22.4462266 AM WpfApp1.exe 23308 CloseFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS
11:47:22.4462380 AM WpfApp1.exe 23308 FileSystemControl C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS Control: FSCTL_QUERY_FILE_REGIONS
11:47:22.4463240 AM WpfApp1.exe 23308 CreateFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
11:47:22.4463757 AM WpfApp1.exe 23308 QueryEAFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS
11:47:22.4520798 AM WpfApp1.exe 23308 CreateFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:47:22.4521047 AM WpfApp1.exe 23308 QueryNetworkOpenInformationFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS CreationTime: 5/9/2022 9:56:21 AM, LastAccessTime: 10/27/2022 11:47:22 AM, LastWriteTime: 10/27/2022 11:47:22 AM, ChangeTime: 10/27/2022 11:47:22 AM, AllocationSize: 4096, EndOfFile: 693, FileAttributes: A
11:47:22.4521134 AM WpfApp1.exe 23308 CloseFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS
11:47:22.4521969 AM WpfApp1.exe 23308 CreateFile C:\Users\user\source\repos\WinFormAppForTesting\WpfApp1\wwwroot\css\app.css SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1659321
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
BlazorWebView on Windows Forms locks CSS files while ...
Run a WinForms blazor app · Open wwwroot\css\app.css · Try to save the file. It will prompt to save as since the file...
Read more >Blazor css file not updating when app is launched
If you are not seeing changes that you have applied to the app.css file, you may need to clear your browser cache, manually....
Read more >Blazor with WPF and WebView2: Scoped CSS files not found
Description I want to integrate the new Blazor WebView in a WPF project. ... App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.
Read more >Blazor Hybrid WPF styling not working
I'm trying to get a new app working using Blazor Hybrid with WPF. ... This project contained all the CSS with the pages...
Read more >What's behind the hype about Blazor?
Blazor is a new client-side UI framework from the ASP.NET team. Its big selling point is the ability to write rich web UI...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You mean who owns it in the VS world? Possibly someone on @vijayrkn 's team?
Closing this out here, @BillHiebert will confirm on VSTS if he’s still running into the issue.