Sdílet prostřednictvím


Registry-Free Profiler Startup and Attach

Starting with the .NET Framework version 4, you can attach profilers at application startup time (startup-load) and while applications are running (attach-load). Both options provide the ability to start up profilers that have not been registered as COM components.

These two methods use different protocols for starting profilers and are discussed in the following sections.

Startup-Load Profilers

A startup-load profiler is loaded when the application to be profiled starts. Before the .NET Framework 4, startup loading was the only way to load a profiler. The profiler had to be registered and was located through the values of the following environment variables:

  • COR_ENABLE_PROFILING=1

  • COR_PROFILER={CLSID of profiler}

The common language runtime (CLR) used the CLSID from COR_PROFILER to locate the profiler in the HKEY_CLASSES_ROOT of the registry.

Starting with the .NET Framework 4, you can continue to register your profiler; however, another environment variable is checked before registry lookup:

  • COR_PROFILER_PATH=full path of the profiler DLL

If COR_PROFILER_PATH is present, its value is used to locate the profiler, and registry lookup is skipped.

Notes:

  • COR_PROFILER_PATH is optional. If you do not specify COR_PROFILER_PATH, the CLSID of the profiler is used to find its path in the registry.

  • If you specify COR_PROFILER_PATH and register your profiler, COR_PROFILER_PATH takes precedence. If COR_PROFILER_PATH points to an invalid path, the profiler fails to load even if it is registered.

  • COR_PROFILER is always required. If you specify COR_PROFILER_PATH, the registry lookup is skipped; however, the CLSID from COR_PROFILER is still required for the CreateInstance call.

Attach-Load Profilers

Starting with the .NET Framework 4, you can attach a profiler to a running application. For more information about this functionality, see Profiler Attach and Detach. An attach-load profiler uses the wszProfilerPath parameter of the ICLRProfiling::AttachProfiler method to find the location of the profiler DLL file. If wszProfilerPath is null, the runtime tries to locate the profiler by looking in the registry for the CLSID that is specified in the pClsidProfiler parameter.

See Also

Other Resources

Profiling Overview

Profiling (Unmanaged API Reference)

Unmanaged API Reference