MZ-Tools Articles Series: HOWTO: Add an error with navigation to the Error List from a Visual Studio add-in
It is conspicuous that the EnvDTE80.ErrorItems collection introduced by VS 2005 lacks an Add method to add errors to the ErrorList, so it was a common belief, apparently even within Microsoft and also mine until recently that only SDK packages can add errors to the ErrorList. There is good news: there is not only one approach, but two!
The first one was explained by Dave Sexton in this forum post and it uses the OutputWindowPane.OutputTaskItemString method but has some limitations.
I was investigating another approach and it was not until today that I became aware of the difference between GetService (that didn’t work in my sample) and GetGlobalService
Of course there is always in the VS automation world something else that doesn’t work as expected such as a +1 line number offset that others have posted in the MSDN forum more than once, but I managed to work around it.
So, here is the second working approach:
HOWTO: Add an error with navigation to the Error List from a Visual Studio add-in
I always get the feeling that the automation model (EnvDTE) should be much more powerful and intuitive (no ErrorItems.Add method but OutputWindowPane.OutputTaskItemString to add errors to the Error List???) than what it is, and that the bridge between the automation model and the SDK is much more complicated that it should be (EnvDTE.DTE lacking a GetService method, assemblies that are only in the GAC or that you need to get installing the SDK that I don’t want to install, IVSHierarchy <-> EnvDTE.Project conversions, 0-based collections vs 1-based collections, etc.). The result is several hours spent making something simple work…