Skip to main content
The 2024 Developer Survey results are live! See the results

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
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 ...
VivekDev's user avatar
  • 24.2k
49 votes
6 answers
13k views

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 ...
Optim's user avatar
  • 653
14 votes
3 answers
12k views

Where are the using statements/directives in .NET 6 and above

I got up and running with Visual Studio 2022 Preview for a couple of days now. Got the first shock, there is no Startup.cs. Thats ok, a bit of reading, I know Startup is removed. Today got another ...
VivekDev's user avatar
  • 24.2k
22 votes
1 answer
18k views

Integration test and hosting ASP.NET Core 6.0 without Startup class

To setup unit tests in previous versions of .NET Core, I could host my web App or web API in a test project the following way: IHost host = Host.CreateDefaultBuilder() .ConfigureWebHostDefaults(...
user2341923's user avatar
  • 4,687
11 votes
1 answer
1k views

Nullability and generics in .NET 6

Let's say we have some generic method with 2 parameters: private void TestConstraints<TKey>(TKey key, TKey? nullableKey) where TKey : notnull { } That's perfectly fine from .NET6 ...
Norritt's user avatar
  • 143
5 votes
1 answer
3k views

Logs not getting written to ApplicationInsights

Here is my .net 6 program.cs basic code. In the Following sample code I am trying to write basic logs into Application insights. I have Nuget package reference in my project file <PackageReference ...
roney's user avatar
  • 1,074
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 ...
VivekDev's user avatar
  • 24.2k
53 votes
5 answers
75k views

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 ...
Jatin Dave's user avatar
18 votes
1 answer
24k views

How to configure NewtonsoftJson with Minimal API in .NET 6.0

I have net6.0 project with minimal api and I would like to use NetwtonsoftJson instead of built in System.Text.Json library for serialization and deserialization. At the moment I have this ...
thug_'s user avatar
  • 1,043
3 votes
1 answer
2k views

How to download files using HttpClient with a ProgressBar?

I created a new class named SiteDownload and added some links to download images: using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; public class ...
Daniel Lip's user avatar
  • 11.2k
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 ...
Nader Gharibian Fard's user avatar
38 votes
2 answers
6k views

FileVersionInfo.ProductVersion suddenly contains git commit hash

I have a .NET 6 WPF project and cannot figure out what changed as the ProductVersion of my assembly suddenly contains a git commit hash. My project file always looked like this, where I also updated ...
grasbueschel's user avatar
  • 1,867
16 votes
1 answer
16k views

How to access DbContext in .NET 6 minimal API Program.cs

I am trying to call EF Core methods on application startup in my Program.cs file, using the .NET 6 minimal API template and get the following error: System.InvalidOperationException: 'Cannot resolve ...
comp32's user avatar
  • 231
2 votes
1 answer
1k views

I need to update state of blazor component when other component changed

I have a blazor page with different components. Component structure is the following: page component1 component11 component2 When event happens on component11, component2 should update ...
Alexan's user avatar
  • 8,495
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 ...
LLuz's user avatar
  • 1,999

15 30 50 per page
1
2 3 4 5
29