Home > Software design >  error CS8773: "Feature 'global using directive' is not available in C# 9.0" afte
error CS8773: "Feature 'global using directive' is not available in C# 9.0" afte

Time:01-18

I have a project that was initially created for .NET 6 but then I needed to downgrade it to .NET 5. I changed Target framework in Project Properties and tried to compile. As a result I received a bunch of the errors:

GlobalUsings.g.cs(2,1,2,29): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater.

File GlobalUsings.g.cs is created automatically and it reappears every time after compilation.

CodePudding user response:

Finally I found that the reason is an extra property ImplicitUsings in the project file that is not supported by .net 5.0.

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

I needed to remove ImplicitUsings from the file.

  •  Tags:  
  • Related