Search code examples
visual-studiorazorblazorrazor-pages

How to find source code line with syntax error in Razor file


I have a Blazor web project, and am getting errors on one rather large page file when I build. There are no errors if I close and relaunch VS 2022, until I build. Then, it says there are 2 errors ("} expected" and "; expected"), but it shows them in the .g file, and when I double-click on the error line in the Error window, nothing happens.

How do I trace to where in the source code the bad lines are? There are 1300 lines of code in this page...


Solution

  • In blazor (VS2022 current version) don't look at the errors tab, always check the "Output" tab, you'll find the errors there, and double clicking on them usually will get you to the correct line.

    the .g files are generated code:

    error the in razor.g.cs file, can't find in VS, can't find the _razor.g.cs file