コード例 #1
0
        public static void RefreshInstances()
        {
            var instances = new List <DebuggerInfo>();
            var retVal    = DebuggerInfo.GetRunningObjectTable(0, out IRunningObjectTable rot);

            if (retVal == 0)
            {
                rot.EnumRunning(out IEnumMoniker enumMoniker);

                var fetched  = IntPtr.Zero;
                var monikers = new IMoniker[1];
                while (enumMoniker.Next(1, monikers, fetched) == 0)
                {
                    var moniker = monikers[0];
                    DebuggerInfo.CreateBindCtx(0, out IBindCtx bindCtx);
                    moniker.GetDisplayName(bindCtx, null, out string displayName);
                    moniker.GetClassID(out var classId);
                    if (displayName.StartsWith("!VisualStudio.DTE"))
                    {
                        try
                        {
                            rot.GetObject(monikers[0], out object obj);
                            instances.Add(new DebuggerInfo(displayName, obj));
                        }
                        catch (COMException)
                        {
                            // the debugger might not be ready at this time
                        }
                    }
                }
            }

            DebuggerInfo.Instances = instances.ToArray();
        }
コード例 #2
0
        public static void RefreshDebuggers(this IDebuggerSupportedViewModel @this)
        {
            @this.Debuggers.Clear();
            DebuggerInfo.RefreshInstances();
            @this.Debuggers.Add(AutomaticDebuggerInfo.Instance);
            foreach (var debugger in DebuggerInfo.Instances)
            {
                @this.Debuggers.Add(debugger);
            }

            @this.SelectedDebugger = AutomaticDebuggerInfo.Instance;
        }
コード例 #3
0
        public static DebuggerInfo PickDebugger(string solutionFile, bool forceRefresh)
        {
            if (forceRefresh || DebuggerInfo.Instances == null || DebuggerInfo.Instances.Length == 0)
            {
                DebuggerInfo.RefreshInstances();
            }

            if (DebuggerInfo.Instances == null || DebuggerInfo.Instances.Length == 0)
            {
                return(null);
            }

            solutionFile = Path.GetFullPath(solutionFile);
            var debugger = DebuggerInfo.Instances.FirstOrDefault(
                d => d.SolutionFileName?.Equals(solutionFile, StringComparison.OrdinalIgnoreCase) ?? false);

            return(debugger ?? DebuggerInfo.Instances.First());
        }