How to get rid of line number error after installing Visual Studio 2022 Q&A

After installation of .NET 6 and Visual Studio 2022 I get errors like: The line number specified for #line directive is missing or invalid on build when using Visual Studio 2019:

Litium version: 8.0

Remove the line <LangVersion>latest</LangVersion> from the file \Src\Directory.Build.props:

<Project>
  <PropertyGroup>
-     <LangVersion>latest</LangVersion>
  </PropertyGroup>
</Project>

Read more

1 Like

You can also set it to 9.0 of the c# specification

<Project>
  <PropertyGroup>
-     <LangVersion>latest</LangVersion>
+     <LangVersion>9.0</LangVersion>
  </PropertyGroup>
</Project>

This is not related to Litium version but to the target framework version. And the error is there because the LangVersion points to the latest version of c# specification. Now with .NET 6 the c# version 10 was released and will be installed together with .NET, this will also impact other sites that using the LangVersion set to latest and pinning the LangVersion to 9 it will be the same behaviour as before .NET 6 was released.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.