private bool AttachProc(bool isLocal) { bool ret = false; EnvDTE80.Debugger2 dbg = (Debugger2)_app.Debugger; //get the active doc //make sure it is one of our test documents //attach to the process foreach (EnvDTE80.Process2 p in dbg.LocalProcesses) { if (p.Name.Contains("sqlservr.exe")) { proc = p; //attach to the managed code engine proc.Attach2("{449EC4CC-30D2-4032-9256-EE18EB41B62B}"); //p.Attach2("{1202F5B4-3522-4149-BAD8-58B2079D704F}"); owp.OutputString(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); //MessageBox.Show(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); ret = true; break; } } return(ret); }
private AttachResult Attach(AttachType attachType) { string engine = _attachTypesMap[attachType]; if (IsBeingDebugged()) { return AttachResult.BeingDebugged; } var dbg = _dte.Debugger as Debugger2; var trans = dbg.Transports.Item("Default"); var eng = trans.Engines.Item(engine); EnvDTE80.Process2 proc = null; try { proc = dbg.GetProcesses(trans, "").Item(_processName) as EnvDTE80.Process2; } catch (Exception ex) { return AttachResult.NotRunning; } proc.Attach2(eng); return AttachResult.Attached; }
void DoneExec(IAsyncResult iar) { try { ExecStmtDel ed = (ExecStmtDel)iar.AsyncState; bool ret = ed.EndInvoke(iar); } finally { if (proc != null) { proc.Detach(false); proc = null;; } } }
private void ResetDepProp() { if (isToolWin) { propForm.Hide(); propForm = null; toolWin.Close(vsSaveChanges.vsSaveChangesNo); isToolWin = false; propForm.FirstLoad = true; } _connString = ""; projPath = ""; proc = null; }
void DoneExec(IAsyncResult iar) { try { ExecStmtDel ed = (ExecStmtDel)iar.AsyncState; bool ret = ed.EndInvoke(iar); } finally { if (proc != null) { proc.Detach(false); proc = null; ; } } }
private bool AttachProc(bool isLocal) { bool ret = false; EnvDTE80.Debugger2 dbg = (Debugger2)_app.Debugger; //get the active doc //make sure it is one of our test documents //attach to the process foreach (EnvDTE80.Process2 p in dbg.LocalProcesses) { if (p.Name.Contains("sqlservr.exe")) { proc = p; //attach to the managed code engine proc.Attach2("{449EC4CC-30D2-4032-9256-EE18EB41B62B}"); //p.Attach2("{1202F5B4-3522-4149-BAD8-58B2079D704F}"); owp.OutputString(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); //MessageBox.Show(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); ret = true; break; } } return ret; }
public void Debug(CacheTestMessage test) { try { AutoTest.Core.DebugLog.Debug.WriteDebug("Starting debug session"); var found = false; var targetFramework = ""; found = setBreakpointFromMethod(test, ref targetFramework); if (!found) { found = setBreakpointFromStacktrace(test, ref targetFramework); } if (!found) { return; } var process = new AutoTestRunnerDebugProcess(); var assembly = test.Assembly; AutoTest.Core.DebugLog.Debug.WriteDebug("Starting process suspended"); var command = ""; var options = new RunOptions(); var runner = new RunnerOptions(getTestRunner(TestRunnerConverter.ToString(test.Test.Runner), test.Assembly, test.Test.Name)); var asm = new AssemblyOptions(test.Assembly); asm.AddTest(test.Test.Name); runner.AddAssembly(asm); options.AddTestRun(runner); AutoTest.Core.DebugLog.Debug.WriteDebug(string.Format("Starting {0}", command)); var processID = process.StartPaused(options, test.Test.Runner); try { AutoTest.Core.DebugLog.Debug.WriteDebug("Locating debugger for Visual Studio " + _application.Version); var dbg2 = (EnvDTE80.Debugger2)_application.Debugger; var trans = (EnvDTE80.Transport)dbg2.Transports.Item("Default"); EnvDTE80.Engine[] dbgeng; if (_application.Version == "9.0") { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed") }; } else { if (process.Framework >= new Version(4, 0)) { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item(string.Format("Managed (v{0}.{1})", process.Framework.Major, process.Framework.Minor)) } } ; else { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed (v2.0, v1.1, v1.0)") } }; } EnvDTE80.Process2 proc2 = null; foreach (EnvDTE80.Process2 proc in dbg2.GetProcesses(trans, null)) { if (proc.ProcessID == processID) { proc2 = proc; break; } } if (proc2 != null) { proc2.Attach2(dbgeng); } } catch (Exception ex) { AutoTest.Core.DebugLog.Debug.WriteException(ex); throw; } finally { AutoTest.Core.DebugLog.Debug.WriteDebug("Resuming process"); process.Resume(); } } catch (Exception ex) { AutoTest.Core.DebugLog.Debug.WriteException(ex); } }