Equivalent to UserSettings / ApplicationSettings in WPF for newer .NET versions

You can add the same old good settings file e.g. via the right click on the Properties -> Add -> New Item and search for the “Settings”. The file can be edited in the settings designer and used as in the .net framework projects before (ConfigurationManager, Settings.Default.Upgrade(), Settings.Default.Save, etc. works). Add also the app.config file … Read more

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

Note that you can switch to generic hosting model (the one using the startup class) if you want. To set up integration tests with the new minimal hosting model you can make web project internals visible to the test one for example by adding next property to csproj: <ItemGroup> <InternalsVisibleTo Include =”YourTestProjectName”/> </ItemGroup> And then … Read more

Where are the using statements/directives in .NET 6

C# 10.0 introduces a new feature called global using directive (global using <fully-qualified-namespace>;) which allows to specify namespaces to be implicitly imported in all files in the compilation. .NET 6 RC1 has this feature enabled by default in new project templates (see <ImplicitUsings>enable</ImplicitUsings> property in your .csproj). For Microsoft.NET.Sdk.Web next namespaces should be implicitly imported … Read more

ASP.NET Core 6 how to access Configuration during startup

WebApplicationBuilder returned by WebApplication.CreateBuilder(args) exposes Configuration and Environment properties: var builder = WebApplication.CreateBuilder(args); // Add services to the container. … ConfigurationManager configuration = builder.Configuration; // allows both to access and to set up the config IWebHostEnvironment environment = builder.Environment; WebApplication returned by WebApplicationBuilder.Build() also exposes Configuration and Environment: var app = builder.Build(); IConfiguration configuration = … Read more