dotnet new api -aot: ‘-aot’ is not a valid option
The correct syntax for generating a project with AOT is --aot
(with 2 hyphens). In this particular case, the correct command would be:
dotnet new api --aot
Code language: Bash (bash)
The correct syntax for generating a project with AOT is --aot
(with 2 hyphens). In this particular case, the correct command would be:
dotnet new api --aot
Code language: Bash (bash)
In C#, you can randomly slect items from a list using Random.GetItems, a method introduced in .NET 8. The method takes in two parameters: There are two important things to note about this method: With all this being said, let’s take a few examples. Let’s assume the following array of choices: For selecting 2 random…
Files opened or saved using WPF’s file dialogs (OpenFileDialog, SaveFileDialog or OpenFolderDialog) are by default added to the Windows Explorer’s recent files list and can also impact the Recommended section of the Start Menu in Windows 11. To disable this behavior, you can set AddToRecent to false on your dialog before calling the ShowDialog() method….
Starting with .NET 8, several new methods have been added to the JsonNode class to help with the deep cloning of nodes and checking whether they are equal or not. The DeepClone() method will create and return a deep clone of the current node and all of its descendants. On the other hand, DeepEquals() will…
.NET 8 introduces several new naming policies that can be used with the System.Text.Json serializer. To name them: Let’s look at the serialized output for each of them. For this, we’re going to use a Car class with the following definition: And we are going to serialize the following object instance: Lower snake case (snake_case)…
If you’re just getting started with interceptors, you might be getting one of the following errors: Error CS0246 The type or namespace name ‘InterceptsLocationAttribute’ could not be found (are you missing a using directive or an assembly reference?) Error CS0246 The type or namespace name ‘InterceptsLocation’ could not be found (are you missing a using…
A new extension method – GetFromJsonAsAsyncEnumerable<T> – has been added to the HttpClient part of .NET 8. This new mthod will take the response body JSON and deserialize it into an async enumerable operation. The complete signature of the extension method is as follows: Let’s take a look at how to use it. First thing…