I have a CLR profiler that I have written which injects code into methods at JIT time. The code I inject depends on .NET 3.5+. How can I detect the version of the .NET Framework that is available at profiler initialization time (ICorProfilerCallback::Initialize
)?
Ideally, if they don't have .NET 3.5+ installed, I would like to simply not have my profiler loaded which means returning CORPROF_E_PROFILER_CANCEL_ACTIVATION
from Initialize
. If I don't detect the version until later (such as on module load) then my profiling flags will be set and certain CLR optimizations will be disabled which is undesirable since the profiler won't actually work.