NativeAOT and the Silhouette library enable building .NET CLR profilers using C# instead of C++. By deriving from base classes like CorProfilerCallbackBase and using the [Profiler] attribute, developers can create native profilers that hook into the CLR's unmanaged profiling APIs. The article demonstrates building a basic profiler that logs assembly loads, showing how Silhouette handles the complex interop boilerplate and exposes profiling events as simple method overrides. The profiler compiles to a self-contained native DLL and attaches via environment variables like CORECLR_ENABLE_PROFILING.
Table of contents
What are the .NET profiling APIs?Who needs C when you have NativeAOT?Writing a .NET profiler in C#Testing our new profilerSummarySort: