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

For the original announcement of .NET 6, and for more detailed information, please refer to the official communication from Microsoft.


.NET 6 delivers the final parts of the .NET unification plan that started with .NET 5. .NET 6 unifies the SDK, base libraries, and runtime across mobile, desktop, IoT, and cloud apps.

is the next big release to the .NET family after .NET 5.

was released November 8th, 2021.

The first preview was made available on February 17th, 2021.

General Improvements :

In addition to this unification, the .NET 6 ecosystem offers:

  • LTS Release: .NET 6 is Supported for three years as the latest long term support (LTS) release.

  • Simplified development : Getting started is easy. New language features in C# 10 reduce the amount of code you need to write. And investments in the web stack and minimal APIs make it easy to quickly write smaller, faster microservices.

  • Better performance : .NET 6 is the fastest full stack web framework, which lowers compute costs if you're running in the cloud.

  • Ultimate productivity : .NET 6 and Visual Studio 2022 provide hot reload, new git tooling, intelligent code editing, robust diagnostics and testing tools, and better team collaboration.


Whats New :

  • C# 10 : All new C# 10 offers language improvements such as record structs, implicit using, and new lambda capabilities, while the compiler adds incremental source generators.

  • F# 6 : F# 6 adds new features including Task based async, pipeline debugging and numerous performance improvements.

  • Minimal APIs : Simplify getting started experience and HTTP services performance improvement.

  • Hot Reload : This feature enables you to skip rebuilding and restarting your app to view a new change — while your app is running — supported in Visual Studio 2022 and from the .NET CLI, for C# and Visual Basic.

  • .NET MAUI : .NET Multi-platform App UI (.NET MAUI) is still in preview, with a release candidate coming in the first quarter of 2022 and general availability (GA) in the second quarter of 2022. .NET MAUI makes it possible to build native client apps for desktop and mobile operating systems with a single codebase.

  • Blazor : ASP.NET Core in .NET 6 improves Blazor. Blazor components can now be rendered from JavaScript and integrated with existing JavaScript based apps.

  • File IO : File IO in .NET 6 has support for symbolic links and has greatly improved performance with a re-written-from-scratch FileStream.

  • Production stress-tested : Production stress-tested with Microsoft services, cloud apps run by other companies, and open source projects.

  • HTTP/3 : .NET 6 includes preview support for HTTP/3, a new version of HTTP. HTTP/3 solves some existing functional and performance challenges by using a new underlying connection protocol called QUIC. QUIC establishes connections more quickly, and connections are independent of the IP address, allowing mobile clients to roam between Wi-fi and cellular networks. For more information, see Use HTTP/3 with HttpClient.

Offical Links

5513 questions
55
votes
7 answers

How can I read the appsettings.json in a .NET 6 console application?

I try to create a .NET 6 Console Application but having troubles reading my appsettings.json file. In a web application I could use this... var builder = WebApplication.CreateBuilder(args); But what would I use in a console application? I get this…
MTplus
  • 2,077
  • 4
  • 34
  • 51
54
votes
3 answers

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 current date and time. I was expecting both…
Arad Alvand
  • 8,607
  • 10
  • 51
  • 71
53
votes
2 answers

Comparing two objects with == operator

I have this code that checks the references of two variables, I came across this case which is a bit confusing : string first = "10"; object second = 10.ToString(); dynamic third = second; Console.WriteLine($"{first == second} {first ==…
Reza Ariyan
  • 721
  • 3
  • 13
46
votes
4 answers

Problem Updating to .Net 6 - Encrypting String

I'm using a string Encryption/Decryption class similar to the one provided here as a solution. This worked well for me in .Net 5. Now I wanted to update my project to .Net 6. When using .Net 6, the decrypted string does get cut off a certain point…
Optim
  • 523
  • 1
  • 5
  • 9
45
votes
4 answers

Can I add a reference to a .NET Framework DLL from a .NET 6 project?

Microsoft recently announced .Net 6.0 as major version. I didn't find any reference where we can use older .NET framework (> 4.7.*) references in .net 6.0 project? Say, a .NET 6 project will have dll reference of .NET Framework 4.7.1 for windows…
Jatin Dave
  • 734
  • 1
  • 7
  • 14
42
votes
6 answers

.NET 6.0 not showing in Visual Studio 2022 (General Release)

I have installed .NET 6.0 SDK and Visual Studio 2022. However, Visual Studio 2022 does not offer the ability to select .NET 6.0. I know I can edit the project file with the target framework so please don't suggest that. This question is specifically…
Oliver
  • 35,233
  • 12
  • 66
  • 78
38
votes
3 answers

How to use WebApplicationFactory in .net6 (without speakable entry point)

In ASP.NET Core 6 default template moves everything from Sturtup.cs into Program.cs, and uses top-level statements in Program.cs, so there's no more (speakable) Program class ether. That looks awesome, but now, I need to test all of this.…
maxc137
  • 2,291
  • 3
  • 20
  • 32
36
votes
1 answer

RNGCryptoServiceProvider is obsolete

I need to generate a token using random numbers and letters. However, the error message is telling me to use RandomNumberGenerator which will only give me random numbers which will not help. error messsage 'RNGCryptoServiceProvider' is obsolete:…
GolfBravo
  • 837
  • 2
  • 12
  • 23
34
votes
3 answers

How to change default port no of my .NET core 6 API

I am trying to change default port from properties section of project but I am not able to see any options. I am using visual studio 2022 with .NET core 6.
Vishal modi
  • 1,571
  • 2
  • 12
  • 20
33
votes
5 answers

How to fix Visual Studio 2022 Warning CA1416 "Call site reachable by all platforms" but "only supported on: 'windows'"?

So I have a C# class library project that I only intend to use on Windows. It contains some classes that use the System.Drawing.Image class which is only available on Windows. After upgrading to Visual Studio 2022 and setting the target framework…
RonC
  • 31,330
  • 19
  • 94
  • 139
30
votes
5 answers

Subtract DateOnly in C#

In C# I can't use subtraction with DateOnly variables, unlike DateTime. Is there any explanation? var a = new DateTime(2000, 01, 01); var b = new DateTime(1999, 01, 01); //var c = a.Subtract(b); var c = a - b; var d = new DateOnly(2000,…
Silenus
  • 667
  • 1
  • 7
  • 16
29
votes
4 answers

How to configure and use Serilog in ASP.NET Core 6?

Since the recently introduced new structure of the Program.cs startup code, the documentation confuses me a bit. In the officially provided Serilog.AspNetCore example and in the Serilog.Sentry example, they use .UseSerilog() on the WebHostBuilder. I…
ˈvɔlə
  • 9,204
  • 10
  • 63
  • 89
27
votes
1 answer

How can I use DateOnly/TimeOnly query parameters in ASP.NET Core 6?

As of .NET 6 in ASP.NET API, if you want to get DateOnly (or TimeOnly) as query parameter, you need to separately specify all it's fields instead of just providing a string ("2021-09-14", or "10:54:53" for TimeOnly) like you can for DateTime. I was…
maxc137
  • 2,291
  • 3
  • 20
  • 32
25
votes
3 answers

Blazor WASM Net 6 Preview 4 Azure AD - There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'

I have a simple Blazor WASM running Net 6 Preview 4 that I setup using this guide: https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory?view=aspnetcore-6.0 The exact code works perfect with Net…
aherrick
  • 19,799
  • 33
  • 112
  • 188
24
votes
6 answers

How to setup AutoMapper in ASP.Net Core 6

How to configure AutoMapper in ASP.Net Core 6 I have a project which is written in .Net 3.1 so we had Startup.cs class. I am migrating it to .net core 6 now when I put the following configuration in my .Net 6 Program.cs …
MJ X
  • 8,506
  • 12
  • 74
  • 99