/// <summary> /// Closes the solution: cancels build, clears solution data, fires the SolutionClosing and SolutionClosed events. /// <remarks> /// Before invoking this method, one should check if the closing was canceled (<see cref="IsClosingCanceled"/>), /// save solution and project data (e.g. files, bookmarks), then invoke CloseSolution(). /// </remarks> /// </summary> internal static void CloseSolution() { // If a build is running, cancel it. // If we would let a build run but unload the MSBuild projects, the next project.StartBuild call // could cause an exception. BuildEngine.CancelGuiBuild(); if (openSolution != null) { CurrentProject = null; OnSolutionClosing(new SolutionEventArgs(openSolution)); openSolution.Dispose(); openSolution = null; ParserService.OnSolutionClosed(); OnSolutionClosed(EventArgs.Empty); CommandManager.InvalidateRequerySuggested(); } }