private void StartProfiler(ProfilerTypes profilerType) { try { bool buildSuccedded = StartBuild(); if (!buildSuccedded) { throw new Exception("Could not build the solution."); } Project startUpProject = GetStartUpProject(); if (startUpProject == null) { throw new Exception("Could not locate a startUp project."); } string assemblyPath = GetOutputAssemblyPath(startUpProject); if (string.IsNullOrEmpty(assemblyPath)) { throw new Exception("Could not locate the output assembly."); } if (Path.GetExtension(assemblyPath) != ".exe") { throw new Exception("The output of the startUp project is not an executable."); } if (!File.Exists(assemblyPath)) { throw new Exception("The output executable file could not be found."); } _window = this.FindToolWindow(typeof(VisualProfilerToolWindow), 0, true) as VisualProfilerToolWindow; if ((null == _window) || (null == _window.Frame)) { throw new NotSupportedException("Cannot create a window."); } UILogic uiLogic = _window.VisualProfilerUIView.UILogic; _window.VisualProfilerUIView.UILogic.MethodClick += mvm => OnMethodClick(uiLogic, mvm); _window.VisualProfilerUIView.Profile(profilerType, assemblyPath); _window.VisualProfilerUIView.DataUpdate += ContainingUnitView.UpdateDataOfContainingUnits; _window.Caption = string.Format("Visual Profiler - {0} Mode", GetModeString(profilerType)); IVsWindowFrame windowFrame = (IVsWindowFrame)_window.Frame; ErrorHandler.ThrowOnFailure(windowFrame.Show()); } catch (Exception e) { MessageBox.Show(e.Message, "Profiler initialization failed.", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void StartProfiler(ProfilerTypes profilerType) { try { bool buildSuccedded = StartBuild(); if (!buildSuccedded) throw new Exception("Could not build the solution."); Project startUpProject = GetStartUpProject(); if (startUpProject == null) throw new Exception("Could not locate a startUp project."); string assemblyPath = GetOutputAssemblyPath(startUpProject); if (string.IsNullOrEmpty(assemblyPath)) throw new Exception("Could not locate the output assembly."); if (Path.GetExtension(assemblyPath) != ".exe") throw new Exception("The output of the startUp project is not an executable."); if (!File.Exists(assemblyPath)) throw new Exception("The output executable file could not be found."); _window = this.FindToolWindow(typeof(VisualProfilerToolWindow), 0, true) as VisualProfilerToolWindow; if ((null == _window) || (null == _window.Frame)) throw new NotSupportedException("Cannot create a window."); UILogic uiLogic = _window.VisualProfilerUIView.UILogic; _window.VisualProfilerUIView.UILogic.MethodClick += mvm => OnMethodClick(uiLogic, mvm); _window.VisualProfilerUIView.Profile(profilerType, assemblyPath); _window.VisualProfilerUIView.DataUpdate += ContainingUnitView.UpdateDataOfContainingUnits; _window.Caption = string.Format("Visual Profiler - {0} Mode", GetModeString(profilerType)); IVsWindowFrame windowFrame = (IVsWindowFrame)_window.Frame; ErrorHandler.ThrowOnFailure(windowFrame.Show()); } catch (Exception e) { MessageBox.Show(e.Message, "Profiler initialization failed.", MessageBoxButton.OK, MessageBoxImage.Error); } }