Questions tagged [.net-6.0]
For questions about Microsoft's .NET application development framework that are specific to version 6.0+ of the framework. Use only If your question are version-specific
.net-6.0
5,916
questions
280
votes
16
answers
253k
views
Non-nullable property must contain a non-null value when exiting constructor. Consider declaring the property as nullable
I have a simple class like this.
public class Greeting
{
public string From { get; set; }
public string To { get; set; }
public string Message { get; set; }
}
Strangely I get the ...
266
votes
14
answers
272k
views
ASP.NET Core 6+ how to access Configuration during startup
In earlier versions, we had Startup.cs class and we get configuration object as follows in the Startup file.
public class Startup
{
private readonly IHostEnvironment environment;
private ...
216
votes
17
answers
143k
views
Publish error: Found multiple publish output files with the same relative path
When I publish my ABP project I get the following error:
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21458.32\Sdks\Microsoft.NET.Sdk
\targets\Microsoft.NET.ConflictResolution.targets(112,5):
error ...
164
votes
16
answers
250k
views
How to use appsettings.json in Asp.net core 6 Program.cs file
I'm trying to access appsettings.json in my Asp.net core v6 application Program.cs file, but in this version of .Net the Startup class and Program class are merged together and the using and another ...
111
votes
7
answers
160k
views
Startup.cs class is missing in .NET 6
I created REST API's in .NET 5 and everything was working perfectly, but recently I moved to .NET 6 and realized that no startup.cs class is present. How do I add the DB Context in .NET 6 since there ...
107
votes
5
answers
60k
views
error CS8773: "Feature 'global using directive' is not available in C# 9.0" after downgrade from net6.0 to net5.0
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 ...
106
votes
31
answers
114k
views
Assets file project.assets.json doesn't have a target for 'net6.0' - VS2022
Just a few days ago got this error, after updating to Visual Studio Community 2022 v17.2 (from v17.1.6):
Error NETSDK1005
Assets file 'C:.........XXXXXX.Web\obj\project.assets.json' doesn't have a ...
105
votes
8
answers
41k
views
Equivalent to UserSettings / ApplicationSettings in WPF for newer .NET versions
What is the prefered way for persisting user settings for WPF applications with .net-5 , .net-6.0, .net-7.0 or .net-core>=3.0?
Where are the .NET user settings gone?
Created WPF .Net Core 3.0 ...
102
votes
4
answers
32k
views
VS 2022 - Convert to file-scoped namespace in all files
I'm converting my project to .NET 6 and I want to use filescoped namespaces everywhere. But the conversion tool exists only in the editor.
Has anyone found out if there's a way to run this editor ...
100
votes
6
answers
58k
views
.NET 6.0 C# "new console template" - how to read CLI arguments?
Now that .NET 6.0 is out, what appears to have be a radical update to the default CLI project template is the absence of the familiar boilerplate being reduced to the following:
// See https://aka.ms/...
98
votes
14
answers
137k
views
.NET6 and DateTime problem. Cannot write DateTime with Kind=UTC to PostgreSQL type 'timestamp without time zone'
I have common problem.
Cannot write DateTime with Kind=UTC to PostgreSQL type 'timestamp
without time zone'
And I want to enable Legacy Timestamp behavoour as is documented here:
https://github.com/...
84
votes
3
answers
43k
views
DateTime.Now equivalent for TimeOnly and DateOnly?
.NET 6 / C# 10 introduced TimeOnly and DateOnly structs, to represent only a time and only a date respectively.
The good old DateTime struct always had a Now static property which would give you the ...
82
votes
15
answers
166k
views
Visual Studio 2019 Not Showing .NET 6 Framework
I've been struggling to change an ASP.NET Core Web API project's target framework to .NET 6 which was started using target framework .NET 5. I've already tried a few options but couldn't find the .NET ...
81
votes
15
answers
129k
views
Throwing ArgumentNullException
Suppose I have a method that takes an object of some kind as an argument. Now say that if this method is passed a null argument, it's a fatal error and an exception should be thrown. Is it worth it ...
80
votes
11
answers
75k
views
Adding ADO.Net Entity Framework gives "The project's target framework does not contain Entity Framework runtime assemblies"
I've added a new .Net 6.0 project to my solution in VS2022. Installed the EntityFramework 6.4.4. with install-package entityframework and now try to add a ADO.Net Entity Framework Model to the project....