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
23
votes
2 answers

Why is the Enumerable.Any(Func predicate) slow compared to a foreach with an if statement when searching a List

Something has piqued my curiosity recently.. Why is the Enumerable.Any(Func predicate) method so much slower than manual foreach, when they do the same thing? I've been messing with some benchmarks and thought of this. I'm checking of…
Michal Diviš
  • 2,008
  • 12
  • 19
23
votes
4 answers

ASP.NET Core 6 Web API - making fields required

I had a basic CRUD API which saves a model to a MongoDB which was working fine. The model looks like the below: [BsonIgnoreExtraElements] public class Configuration { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id {…
Aneef
  • 3,641
  • 10
  • 43
  • 67
22
votes
3 answers

Add methods to Program.cs in .NET 6

In the Program.cs for .NET 5, you could add methods under the Main(string[] args) method. With .NET 6, the Main method exists, but isn't physically included in the Program.cs file by default. To that end, I'm wondering how you add methods to…
AliveInTheCircuits
  • 223
  • 1
  • 2
  • 6
22
votes
3 answers

NuGet System.Drawing.Common .NET 6 CA1416 This call site is reachable on all platforms. 'Image.FromStream(Stream)' is only supported on: 'windows'

Upgrading NuGet System.Drawing.Common to 6.0.0 causes the following error: CA1416 This call site is reachable on all platforms. 'Image.FromStream(Stream)' is only supported on: 'windows'. https://www.nuget.org/packages/System.Drawing.Common/ The…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
21
votes
3 answers

the configuration file 'secrets.json' was not found and is not optional (.NET 6)

User Secrets error is being generated in a CI/CD pipeline, when secrets.json file shouldn't be expected. Steps: Create .NET 5 project Added user secrets. Code runs locally and in CI/CD pipelines. Upgrade to .NET 6 project (and preview NuGet 6.*…
Mehdi Daustany
  • 1,018
  • 4
  • 10
  • 23
20
votes
2 answers

Microsoft.Extensions.Hosting.HostFactoryResolver+HostingListener+StopTheHostException

I'm using Asp.Net Core Web Api 6 I'm facing an error when migrating my DbContext and when updating the database The Error [17:07:29 INF] Application Is Starting [17:07:29 FTL] Application terimnated…
20
votes
6 answers

Docker .Net 6 error Program does not contain a static 'Main' method suitable for an entry point

I'm trying to build my docker image but i'm getting this error. error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/6GAG.WebApi/6GAG.WebApi.csproj] I have 3 projects in 1 solution. 1 webapi 1 frontend…
20
votes
2 answers

ASP.NET Minimal API - Access IConfiguration

Is it possible to access the the IConfiguration in the new ASP.NET Minimal API? I do not see the possibility to do such thing. using Microsoft.AspNetCore.Components; using MudBlazor.Services; var builder = WebApplication.CreateBuilder(args); //…
serious
  • 525
  • 10
  • 21
19
votes
4 answers

Could not load type 'MediatR.ServiceFactory'

I'm creating an Api and I am also using mediatR, I have created my commands, queries, handlers, but when I try to launch my Api I get this error message in my program class: Could not load type 'MediatR.ServiceFactory' from assembly 'MediatR,…
19
votes
3 answers

Why does System.Text.Json throw a `NotSupportedException` for `System.IntPtr` when I'm not using `System.IntPtr`?

I have a .NET Framework 4.8 / AngularJS app that I'm trying to upgrade to .NET 6 so that I can start experimenting with newer front-end frameworks (like Blazor). The upgrade is going okay, but I consistently see this error when calling one of my API…
Keegan Kozler
  • 361
  • 1
  • 3
  • 9
19
votes
3 answers

Compiling C# project to WebAssembly

I need to compile a C# project to WebAssembly and be able to call some methods from JavaScript. I want to use it in an old ASP.NET MVC 4 application that needs to add some new features and I prefer to use C# instead JavaScript/TypeScript. Ideally I…
vcRobe
  • 1,671
  • 3
  • 17
  • 35
18
votes
2 answers

Which SignalR package to install for a .NET 6 server project?

I have a NET6 project which is built part of a larger .NET 6 ASP.NET solution. The project still references: Microsoft.AspNetCore.SignalR, and Microsoft.AspNetCore.SignalR.Core Which have now been marked as deprecated. What packages do I need to…
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
18
votes
3 answers

ASP.NET Core 6 how to access IWebHostEnvironment before builder.Build() in Program.cs

I want to use Environment.IsDevelopment() before builder.Build() in Program.cs. How should I do that? var builder = WebApplication.CreateBuilder(args); //Code: reach environment var app = builder.Build();
nima ansari
  • 434
  • 9
  • 19
18
votes
6 answers

MAUI how to remove the Title Bar and fix the window size?

How can I remove the Title Bar in MAUI and fix the window size as 800x400 pixels in the Windows version of the application? full size I searched for a very long time in the Internet, but I found already not actual information for later versions of…
18
votes
4 answers

Running .NET 6 project in Docker throws Globalization.CultureNotFoundException

I have upgraded API project from .NET 5 to .NET 6 successfully and running fine when executed locally (without Docker). I have also updated the version in Dockerfile from "5.0-alpine3.13" to "6.0-alpine3.14" as below (only change I made). ARG…
Bhanu
  • 831
  • 3
  • 13
  • 28