Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

674
Vistas
Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater - Error on one machine but works on another

When using Visual Studio Enterprise 16.3.7 on two separate machines one builds fine and the other machine throws the error:

Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater.

enter image description here

enter image description here

This can easily be solved on the none working machine by setting LangVersion in .csproj as suggested here https://stackoverflow.com/a/48085575/3850405 or let Visual Studio automatically fix it like the print screen above.

<LangVersion>8.0</LangVersion>

What I can't understand is why one machine builds fine without this line in .csproj and the other machine needs it?

over 4 years ago · Santiago Trujillo
9 Respuestas
Responde la pregunta

0

I downloaded the latest version of .Net Core 3.0 and 3.1 and had the same issue. For me, the fix seemed to download the latest update for Visual Studio 2019 (to version 16.4.2).

This also restarted my computer and the error went away.

over 4 years ago · Santiago Trujillo Denunciar

0

I received the same error, but I had simply forgotten to include the

<LangVersion>8.0</LangVersion>

attribute in ALL the .csproj files in the solution. The following is my current c# 8 setup:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <Nullable>enable</Nullable>
    <NullableContextOptions>enable</NullableContextOptions>
  </PropertyGroup>

I found the following documents to be the most helpful when migrating from core 2.2 to 3.x:

MSDN 2.2 -> 3.0

MSDN 3.0 -> 3.1

over 4 years ago · Santiago Trujillo Denunciar

0

I had to update Visual Studio to version from 16.3.X to 16.4.2. This resolved the problem and I didn't have to add any LangVersion.

Credits: https://github.com/aspnet/AspNetCore.Docs/issues/16047

over 4 years ago · Santiago Trujillo Denunciar

0

I did the following and it solved my issue:

  1. create a file named "Directory.Build.props" in the solution directory and writing this code:

    <Project>
     <PropertyGroup>
      <LangVersion>latest</LangVersion>
     </PropertyGroup>
    </Project>
    
  2. Deleted the .vs folder (it is hidden in the solution directory)

  3. Restart the Visual Studio

over 4 years ago · Santiago Trujillo Denunciar

0

2021

Cause: You may be targeting .NET Standard 2.0, which uses C# 7.3.

Fix: Under the project's Properties, click on the Application panel and choose .NET Standard 2.1 as the Target framework.

After the above change, Visual Studio 2019 will fix the issue by itself, and no LangVersion setting will be necessary.

See: C# language versioning

enter image description here

over 4 years ago · Santiago Trujillo Denunciar

0

This can be because the compiler uses by default different C# language versions for different Target Frameworks.

To override the default C# language, add to project file (as suggested in question):

<PropertyGroup>
   <LangVersion>8.0</LangVersion>
</PropertyGroup>

or:

<PropertyGroup>
   <LangVersion>latest</LangVersion>
</PropertyGroup>

Note:
C# 8.0 is supported only on .NET Core 3.x and newer versions. Many of the newest features require library and runtime features introduced in .NET Core 3.x.
Source: C# language versioning - Microsoft Docs


See C# language versioning - Microsoft Docs for the default C# language versions for the different target frameworks and how to manually select the C# language version.

See also the stack overflow answer Does C# 8 support the .NET Framework? for more information on this topic.


Here is part of the C# language versioning - Microsoft Docs article:

C# language versioning

The latest C# compiler determines a default language version based on your project's target framework or frameworks. Visual Studio doesn't provide a UI to change the value, but you can change it by editing the csproj file. The choice of default ensures that you use the latest language version compatible with your target framework. You benefit from access to the latest language features compatible with your project's target. This default choice also ensures you don't use a language that requires types or runtime behavior not available in your target framework. Choosing a language version newer than the default can cause hard to diagnose compile-time and runtime errors.

The rules in this article apply to the compiler delivered with Visual Studio 2019 or the .NET SDK. The C# compilers that are part of the Visual Studio 2017 installation or earlier .NET Core SDK versions target C# 7.0 by default.

C# 8.0 is supported only on .NET Core 3.x and newer versions. Many of the newest features require library and runtime features introduced in .NET Core 3.x.

Defaults

The compiler determines a default based on these rules:

╔══════════════════╦═════════╦═════════════════════════════╗
║ Target framework ║ version ║ C# language version default ║
╠══════════════════╬═════════╬═════════════════════════════╣
║ .NET             ║ 6.x     ║ C# 10                       ║
║ .NET             ║ 5.x     ║ C# 9.0                      ║
║ .NET Core        ║ 3.x     ║ C# 8.0                      ║
║ .NET Core        ║ 2.x     ║ C# 7.3                      ║
║ .NET Standard    ║ 2.1     ║ C# 8.0                      ║
║ .NET Standard    ║ 2.0     ║ C# 7.3                      ║
║ .NET Standard    ║ 1.x     ║ C# 7.3                      ║
║ .NET Framework   ║ all     ║ C# 7.3                      ║
╚══════════════════╩═════════╩═════════════════════════════╝

Override a default

If you must specify your C# version explicitly, you can do so in several ways:

  • Manually edit your project file.
  • Set the language version for multiple projects in a subdirectory.
  • Configure the LangVersion compiler option.

Edit the project file

You can set the language version in your project file. For example, if you explicitly want access to preview features, add an element like this:

<PropertyGroup>
   <LangVersion>preview</LangVersion>
</PropertyGroup>

The value preview uses the latest available preview C# language version that your compiler supports.

Configure multiple projects

To configure multiple projects, you can create a Directory.Build.props file that contains the <LangVersion> element. You typically do that in your solution directory. Add the following to a Directory.Build.props file in your solution directory:

<Project>
 <PropertyGroup>
   <LangVersion>preview</LangVersion>
 </PropertyGroup>
</Project>

Now, builds in every subdirectory of the directory containing that file will use the preview C# version. For more information, see the article on Customize your build.

C# language version reference

The following table shows all current C# language versions. Your compiler may not necessarily understand every value if it's older. If you install the latest .NET SDK, then you have access to everything listed.

╔═══════════════════════╦══════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Value                 ║ Meaning                                                                                                  ║
╠═══════════════════════╬══════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ preview               ║ The compiler accepts all valid language syntax from the latest preview version.                          ║
║ latest                ║ The compiler accepts syntax from the latest released version of the compiler (including minor version).  ║
║ latestMajor (default) ║ The compiler accepts syntax from the latest released major version of the compiler.                      ║
║ 10.0                  ║ The compiler accepts only syntax that is included in C# 10 or lower.                                     ║
║ 9.0                   ║ The compiler accepts only syntax that is included in C# 9 or lower.                                      ║
║ 8.0                   ║ The compiler accepts only syntax that is included in C# 8.0 or lower.                                    ║
║ 7.3                   ║ The compiler accepts only syntax that is included in C# 7.3 or lower.                                    ║
║ 7.2                   ║ The compiler accepts only syntax that is included in C# 7.2 or lower.                                    ║
║ 7.1                   ║ The compiler accepts only syntax that is included in C# 7.1 or lower.                                    ║
║ 7                     ║ The compiler accepts only syntax that is included in C# 7.0 or lower.                                    ║
║ 6                     ║ The compiler accepts only syntax that is included in C# 6.0 or lower.                                    ║
║ 5                     ║ The compiler accepts only syntax that is included in C# 5.0 or lower.                                    ║
║ 4                     ║ The compiler accepts only syntax that is included in C# 4.0 or lower.                                    ║
║ 3                     ║ The compiler accepts only syntax that is included in C# 3.0 or lower.                                    ║
║ ISO-2 (or 2)          ║ The compiler accepts only syntax that is included in ISO/IEC 23270:2006 C# (2.0).                        ║
║ ISO-1 (or 1)          ║ The compiler accepts only syntax that is included in ISO/IEC 23270:2003 C# (1.0/1.2).                    ║
╚═══════════════════════╩══════════════════════════════════════════════════════════════════════════════════════════════════════════╝
over 4 years ago · Santiago Trujillo Denunciar

0

You must forget this tag in one of your PropertyGroup 's in your *.csproj file

<LangVersion>8.0</LangVersion>

over 4 years ago · Santiago Trujillo Denunciar

0

If you install resharper, it will automatically modify the csproj files for you ;)

over 4 years ago · Santiago Trujillo Denunciar

0

Check that you have valid configuration on both machines (Debug/Release, x64/Any CPU). This could also result to this error.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda