.Net application – C# – resolving error – S8370 Feature ‘nullable reference types’ is not available in C# 7.3. Please use language version 8.0 or greater.

Hi All,
Greetings for the day!!!
Today new issue and solution. Today’s issue bit different than Microsoft 365. Its related to C#.
I am not C# expert but still sharing since it save time.
Background
- I am working .NET application where I am accessing Graph APIs.
- I am using Visual Studio 2022.
- I am using .Net Framework 4.8. This is the default framework coming for me. Though I was looking for .NET framework 8.0.

fig : C# – Windows Application
- For storing client app id and other details I am using “Settings” class which is derived from “System.Configuration.ApplicationSettingsBase” class.
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
- I have added my custom class called “GraphHelper.cs” for authenticating Graph APIs.
- In this class I have “Setting” class nullable instance as
namespace MS_Graph_Demo
{
internal class GraphHelper
{
// Settings object
private static Settings? _settings;
// App-ony auth token credential
private static ClientSecretCredential? _clientSecretCredential;
}//cs
}//ns
- Here, in above code on declaration of “Settings” instance I am getting an error as
Issue

Error (active) CS8370 Feature ‘nullable reference types’ is not available in C# 7.3. Please use language version 8.0 or greater.
Cause
- My project is configured for C# 7.3, we need to change the language version.
Solution
- Once we have configured our project for C# 8.0, and with Nullable Reference Types enabled, Roslyn, the C# compiler, will understand nullability annotations. It will give code analysis based on them.
- We can enable “nullable reference types” feature for the whole project.
- To enable Nullable Reference Types for all code in a project, we need to update the .CSPROJ file
- Close the solution in Visual Studio.
- Open the .CSPROJ file in text editor (I am opening in NOTEPAD) and add the below lines in .CSPROJ file as
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>

- Open the solution in Visual Studio.
- Build it again and solution get successfully build.
Have a wonderful day ahead!!!
Thanks for reading !!!
REFERENCES
- Configure C# language version – https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version

You must be logged in to post a comment.