public override bool Launch() { StopService(ServiceName, StopCommand); ClrConfig config = new ClrConfig { ProfilingMode = ProfilingMode, ListenPort = ListenPort, WaitForConnection = WaitForConnection, IncludeNative = IncludeNative, SamplingInterval = SamplingInterval, CounterInterval = CounterInterval, AllowMethodInlining = AllowMethodInlining, TrackGC = TrackGC, TrackAllocs = TrackAllocs, WeightedSampling = WeightedSampling, }; string configString = config.ToString(); string[] profEnv = LauncherCommon.CreateProfilerEnvironment(configString, LauncherCommon.GetCounterString(PerformanceCounters), true); string serviceAccountSid = null; string serviceAccountName = LauncherCommon.GetServiceAccountName(ServiceName); if (serviceAccountName != null && serviceAccountName.StartsWith(@".\")) { serviceAccountName = Environment.MachineName + serviceAccountName.Substring(1); } if (serviceAccountName != null && serviceAccountName != "LocalSystem") { serviceAccountSid = LauncherCommon.GetAccountSid(serviceAccountName); } if (serviceAccountSid != null) { //set environment for target account LauncherCommon.SetAccountEnvironment(serviceAccountSid, profEnv); } else { string[] baseEnv = LauncherCommon.GetServicesEnvironment(); baseEnv = LauncherCommon.ReplaceTempDir(baseEnv, Path.GetTempPath()); string[] combinedEnv = LauncherCommon.CombineEnvironments(baseEnv, profEnv); LauncherCommon.SetEnvironmentVariables(ServiceName, combinedEnv); } bool returnVal = true; StartService(ServiceName, StartCommand); Thread.Sleep(1000); using (var engine = new DummyDataEngine()) { var progress = new ConnectProgress("localhost", ListenPort, engine, 10); progress.ShowDialog(); if (progress.Client != null) { progress.Client.Dispose(); } else { returnVal = false; } } if (serviceAccountSid != null) { LauncherCommon.ResetAccountEnvironment(serviceAccountSid, profEnv); } else { LauncherCommon.DeleteEnvironmentVariables(ServiceName); } return(returnVal); }