Could not load file or assembly ‘System.Runtime, Version=7.0.0.0…’ – After installing .NET Core 7 ‘dotnet watch run’ not working

According to the Microsoft document, the SDK uses the latest installed version and this is an expected behavior: The .NET CLI must choose an SDK version for every dotnet command. It uses the latest SDK installed on the machine by default, even if the project targets an earlier version of the .NET runtime. So, it … Read more

System.Text.Json: How do I specify a custom name for an enum value?

This is not currently supported out of the box in .net-core-3.0, .net-5, .net-6.0 or .net-7.0. There is currently an issue Support for EnumMemberAttribute in JsonConverterEnum #31081[1] requesting this functionality. In the interim, you will need to create your own JsonConverterFactory that serializes enums with custom value names specified by attributes. If you need to round-trip … Read more

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