question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WPF & Winforms with Blazor app leak 2 file system handles every time app.css is saved

See original GitHub issue

Steps to reproduce:

  1. Create a WPF or Winforms app and enable Blazor as described here Build a Windows Presentation Foundation (WPF) Blazor app | Microsoft Learn
  2. Run the application
  3. In VS, save wwwroot\css\app.css
  4. Run the sys internals tool handle.exe on that file path and you will see the number of open handles increase by 2.
  5. 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:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Eiloncommented, Nov 2, 2022

You mean who owns it in the VS world? Possibly someone on @vijayrkn 's team?

0reactions
TanayParikhcommented, Nov 17, 2022

Closing this out here, @BillHiebert will confirm on VSTS if he’s still running into the issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found