[SOLVED] Error CS8400 Feature ‘global using directive’ is not available in C# 8.0. Please use language version 10.0 or greater.

Posted by

The error you’re encountering in Visual Studio indicates that your project is using a C# language feature, specifically the “global using directive,” which is not supported in the C# version currently configured for your project. This feature is available in C# 10.0 and later, but your project is using C# 8.0.

Here’s how you can resolve this issue:

1. Update the Project’s Target Framework

The “global using directive” requires C# 10 or later, which is supported starting from .NET 6. First, ensure your Visual Studio installation includes the .NET 6 SDK or later. Then, update your project’s target framework:

  1. Open your project in Visual Studio.
  2. Right-click on the project in Solution Explorer and select ‘Properties’.
  3. In the ‘Application’ tab, change the ‘Target framework’ to .NET 6.0 or later. If .NET 6.0 or newer versions are not listed, you may need to install the appropriate SDK from the .NET website.

2. Update the C# Language Version

If you prefer to stay with .NET Core 3.1 and still want to solve the issue without updating the .NET version, you will need to remove or modify the use of global using directives. However, if updating the .NET version, ensure the C# language version is set to use version 10.0 or newer:

  1. Right-click on your project in Solution Explorer and select ‘Edit Project File’.
  2. Add or update the LangVersion tag within the PropertyGroup tag as follows:
  1. Save the changes and close the editor.

3. Rebuild the Project

After making these changes:

  1. Go to ‘Build’ in the menu.
  2. Click ‘Rebuild Solution’.

This should resolve the error by either updating the environment to support the feature or by modifying the project settings to not require it.