public static int GetConsoleSessionIdInternal() { ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect(); ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection("TestRuntime", true); return(connection.UserSessionGetConsoleSessionId()); }
public static bool DisconnectInternal(int sessionId) { ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect(); ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection("TestRuntime", true); return(connection.UserSessionDisconnect(sessionId)); }
/// <summary> /// Start an cdb process that will attach to the given process.. /// </summary> /// <param name="process">Process to attach debugger to.</param> /// <returns>Active cdb process.</returns> /// <exception cref="ApplicationException">Process fails to start or ExecutionService is not running.</exception> private static CdbCommunicationProxy AttachDebugger(Process process) { EnsureDebuggers(); ExecutionServiceClient executionService = ExecutionServiceClient.Connect(); if (executionService == null) { throw new ApplicationException("ExecutionService not found."); } string systemDrive = Environment.ExpandEnvironmentVariables("%SYSTEMDRIVE%"); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = string.Format("{0}\\debuggers\\cdb.exe", systemDrive); startInfo.Arguments = string.Format("-p {0}", process.Id); startInfo.UseShellExecute = false; startInfo.CreateNoWindow = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = true; if (!File.Exists(startInfo.FileName)) { throw new InvalidOperationException(string.Format("Cannot debug failure, debuggers are not installed on this machine. Please install debuggers from http://dbg to '{0}'.", startInfo.FileName)); } // Launch CDB as an elevated process so that it has permissions to attach. Process session = executionService.StartProcess( startInfo, ExecutionUserContext.FirstActiveSessionUser, ExecutionPrivileges.Administrator, true); if (session.HasExited) { throw new ApplicationException(string.Format("Remote debugging session failed to startup: Commandline='{0} {1}', exit code='{2}'.", startInfo.FileName, startInfo.Arguments, session.ExitCode)); } session.PriorityClass = ProcessPriorityClass.High; return(new CdbCommunicationProxy(session)); }