public static void LoadSOSorPSSCOR() { var d = Debugger.Current; string clr = d.Execute("lmvm clr"); Regex regex = new Regex( @"File\sversion\:\s+(?<major>\d)\.(?<minor>\d)\.(?<ver>\d+)\.(" + @"?<build>\d+)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); Match match = regex.Match(clr); DllVersionInfo ver; if (!match.Success) { var mscorwks = d.Execute("lmvm mscorwks"); match = regex.Match(mscorwks); if (!match.Success) { throw new Exception("unable to find mscorwks or clr dll"); } } ver = new DllVersionInfo() { Major = Convert.ToInt32(match.Groups["major"].Value), Minor = Convert.ToInt32(match.Groups["minor"].Value), Version = Convert.ToInt32(match.Groups["ver"].Value), BuildNumber = Convert.ToInt32(match.Groups["build"].Value) }; if (ver.Major > 2 && ver.Version > 300) { d.Require("sos.dll"); } else { switch (ver.Major) { case 1: d.Require("psscor.dll"); break; case 2: d.Require("psscor2.dll"); break; case 4: d.Require("psscor4.dll"); break; default: d.Require("sos.dll"); break; } } }
public static void LoadSOSorPSSCOR() { var d=Debugger.Current; string clr = d.Execute("lmvm clr"); Regex regex = new Regex( @"File\sversion\:\s+(?<major>\d)\.(?<minor>\d)\.(?<ver>\d+)\.(" + @"?<build>\d+)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); Match match = regex.Match(clr); DllVersionInfo ver; if (!match.Success) { var mscorwks = d.Execute("lmvm mscorwks"); match = regex.Match(mscorwks); if (!match.Success) throw new Exception("unable to find mscorwks or clr dll"); } ver = new DllVersionInfo() { Major = Convert.ToInt32(match.Groups["major"].Value), Minor = Convert.ToInt32(match.Groups["minor"].Value), Version = Convert.ToInt32(match.Groups["ver"].Value), BuildNumber = Convert.ToInt32(match.Groups["build"].Value) }; if (ver.Major > 2 && ver.Version > 300) { d.Require("sos.dll"); } else { switch (ver.Major) { case 1: d.Require("psscor.dll"); break; case 2: d.Require("psscor2.dll"); break; case 4: d.Require("psscor4.dll"); break; default: d.Require("sos.dll"); break; } } }