public static bool Attach(Process process, VisualStudioVersions vsVersion = VisualStudioVersions.Automatic) { MessageFilter.Register(); try { if (vsVersion == VisualStudioVersions.Automatic) { var attachSucceed = false; foreach (var progId in DteProgIds.Values) { try { DebuggerLauncher.TryAttachDebugger(process, progId); attachSucceed = true; break; } catch (Exception) { // ignored } } if (attachSucceed) { return(true); } MessageBox.Show( "Unable to launch and attach to debugger, make sure you have Visual Studio (2010/2012/2013/2015) installed correctly.", "Launch and Debug", MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } else { try { DebuggerLauncher.TryAttachDebugger(process, DteProgIds[vsVersion]); return(true); } catch (Exception exception) { MessageBox.Show( $"Unable to launch and attach to debugger, make sure you have Visual Studio of selected version installed correctly.\n\nError: {exception.Message}", "Launch and Debug", MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } } } finally { MessageFilter.Revoke(); } }
public void AttachProcess(Process process) { if (DebuggerLauncher.Attach(process, this.VSVersion)) { App.ReportStatus("Debugger attached successfully."); } else { App.ReportStatus("Failed to attach a debugger."); } }
public DebuggerInfo(VisualStudioVersions vsVersion, string name, bool alwaysAvailable = false) { this.VSVersion = vsVersion; this.Name = name; this.IsAvailable = alwaysAvailable || DebuggerLauncher.GetDebuggerAvailability(vsVersion); }