ErrorListProvider's provide errors to the error list toolwindow. To display (or access) existing errors, you can use the ToolWindows.ErrorList as Klaus suggested. The sample code in the documentation isn't exactly correct. It looks like it was lifted from a custom add-in project, which is now obsolete. With those older add-in projects the applicationObject often referred to the DTE interface.
From a VSSDK Package you'd do something similar to the following:
using System;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
using EnvDTE80;
namespace GetErrorsDemo
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(GetErrorsDemoPackage.PackageGuidString)]
[ProvideMenuResource("Menus.ctmenu", 1)]
public sealed class GetErrorsDemoPackage : AsyncPackage
{
public const string PackageGuidString = "90adc626-67bd-42d5-babc-6e4c5aa6e351";
public static readonly Guid CommandSet = new Guid("5a7f888e-8767-4a4a-a06b-1b06c4f1e3f4");
public const int ErrorsListCommand = 0x0100;
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
// add our menu handler
OleMenuCommandService commandService = await this.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
Assumes.Present(commandService);
var menuCommandID = new CommandID(CommandSet, ErrorsListCommand);
var menuItem = new MenuCommand(this.OnErrorsListCommand, menuCommandID);
commandService.AddCommand(menuItem);
}
private void OnErrorsListCommand(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
DTE2 dte = (DTE2)GetService(typeof(SDTE));
Assumes.Present(dte);
ErrorList errorList = dte.ToolWindows.ErrorList;
for (int i = 1; i <= errorList.ErrorItems.Count; i++)
{
string msg = string.Format("Description: {0}", errorList.ErrorItems.Item(i).Description);
VsShellUtilities.ShowMessageBox(this, msg, "GetErrors Demo", OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}
}
}