C# compiler throws Language Version (LangVersion) reference error "Invalid 'nullable' value: 'Enable' for C# 7.3"
10,946
You should try <LangVersion>preview</LangVersion>
as the error message suggests.
Author by
dnf
Updated on June 04, 2022Comments
-
dnf about 2 years
I have solution with couple .NET Standard projects in all I wanted to enable c# 8 and nullable like below:
<PropertyGroup> <TargetFramework>netstandard2.1</TargetFramework> <LangVersion>8.0</LangVersion> <Nullable>enable</Nullable> </PropertyGroup>
The problem is that some projects are compiling fine and some have error:
Invalid 'nullable' value: 'Enable' for C# 7.3. Please use language version 'preview' or greater
I have Visual Studio 16.2 Preview 2 and .NET Core 3 Preview 6. Is this a bug in preview or I'm doing something wrong?
-
Panagiotis Kanavos about 5 yearsNo repro. I use
8.0
too. Do you have aglobal.json
in those failing projects that points to an earlier SDK?
-
-
dnf about 5 yearsWith preview error message is the same
-
Panagiotis Kanavos about 5 years
preview
is8.0
at this point in time. -
Avin Kavish about 5 yearsIt is not recognized as 8.0 till after release.
-
crakama over 2 yearsIf you right click on your project, navigate to "Properties" >> "Build" >> "Advanced" >> "Language Version" you will notice that visual studio does not provide UI to change the value, You may need to Navigate to the csproj file (by right click on each of your project in visual studio and select "Unload Project", to open up the csproj file) of all your projects under your solution and add <LangVersion>preview</LangVersion>. This settings will help your latest C# compiler determine the default language version based on your projects targets framework.