Starting a process as normal user from a process running as Administrator

 
 
  • Gérald Barré
If you start a process from a process running as Administrator, the child process also run as Administrator. Running a process as Administrator could be a security risk. So, a good practice is to use the minimum privileges required to run a process. If you want to start a process as normal user from a process running as Administrator, you need to use create a limited token and use CreateProcessWithUserW… [read more]

Killing all child processes when the parent exits (Job Object)

 
 
  • Gérald Barré
A Job Object allows groups of processes to be managed as a unit. This is useful for managing the lifetime of a group of processes, for example, when you want to terminate a group of processes when one of them terminates. It is also useful for managing the resources consumed by a group of processes, for example, when you want to limit the amount of memory consumed by a group of processes. One use case of… [read more]

New rules for Blazor in Meziantou.Analyzer

 
 
  • Gérald Barré
Static analysis is a great way to improve the quality of your code and detect errors before they happen. Blazor is has some dynamic parts, so some errors occur only at runtime. In this post, I describe the recent updates in Meziantou.Analyzer to detect some of these errors at compile-time. Meziantou.Analyzer is a NuGet package that provides a set of analyzers to improve the quality of your C# code. It… [read more]

Configuring Visual Studio to manage using directives automatically

 
 
  • Gérald Barré
With recent version of Visual Studio, you don't need to manage using directives manually. Indeed, VS can add/remove them automatically. So, showing them is just a waste of space in the editor. Hopefully, Visual Studio has new options to hide them by default! Let's see how to configure Visual Studio to handle using directives automatically. Collapsing using directives automatically When you open a file, VS… [read more]

Publishing a NuGet package using GitHub and GitHub Actions

 
 
  • Gérald Barré
In the previous post, I explained the best practices for NuGet packages. In this post, I will show how to create and publish a NuGet package that follow best practices using GitHub and GitHub Actions. Create the project Let's create a class library project and a test project: # Create a class library project and a test project dotnet new classlib -o SampleNuGet dotnet new xunit -o SampleNuGet.Tests dotnet… [read more]

How to generate a dump file of a .NET application

 
 
  • Gérald Barré
When an application is not running well, it could be useful to generate a dump file to debug it. There are many ways to generate a dump file on Windows, Linux, or Azure. Windows dotnet-dump (Windows) The dotnet-dump global tool is a way to collect and analyze dumps for .NET Core applications. Install dotnet-dump (require .NET SDK) or download it dotnet tool install --global dotnet-dump Find the process id… [read more]