Here are the steps to profile Visual Studio ASP.NET Development Web Server using NP .NET Profiler.
Click the image for a larger view
NP .NET Profiler is developed using ICorProfiler interfaces . These interfaces are triggered by CLR Runtime only if certain environment variables are set. So to profile any .NET application we have to set the environment variables and restart the process. (For .NET 4.0 and above, we can do few profiler operations without the process restart) A child process’s environment variables are set by parent process’s environment variables. Here the ASP.NET Web Development Server is launched by Visual Studio. So we have to restart the parent process – Visual Studio, so that it reads the new profiler related environment variables and pass these variables to its child process – ASP.NET Web Development Server.
Here is screenshot from Process Explorer : note the WebDev.WebServer40.exe is under devenv.exe
In the current release (22.214.171.124), there is a bug which fails to set the right environment variables. Because of this bug, CLR runtime doesn’t load the profiler dll and NP.exe always displays the message “waiting for process to start…” forever.
Even after clicking on the “Stop Profiling” button in NP .NET Profiler tool, the ASP.NET Development Server is still running and is still holding on to the log files. These logs files are closed only when the ASP.NET Development Server is stopped.