When installing add-ins for Visual Studio, a number of different paths can be used. One of them is
C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvSharedAddins – in a default installation of a US English Windows. Obviously a proper installer would use
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) to make sure the path is correct for the current system and for the current language. For example, for a German system the result would be
C:\Dokumente und Einstellungen\Alle Benutzer\Anwendungsdaten\Microsoft\MSEnvSharedAddins.
Now, the funny thing is that a part of the path is stored by Visual Studio verbatim. To be precise, VS stores the path as
%ALLUSERSPROFILE%\Application Data\Microsoft\MSEnvSharedAddins, as you can see in VS using Tools/Options/Add-in/Macros Security.
I saw this question on a newsgroup: How do you access the properties of a project via the EnvDTE VS extensibility interface? It’s really quite simple, like in this code:
Sub AccessProject() Dim proj As Project proj = DTE.Solution.Projects.Item(1) Dim prop As [Property] For Each prop In proj.Properties Debug.Print("Project property " & prop.Name & " = " & prop.Value) Next Dim projItem As ProjectItem For Each projItem In proj.ProjectItems Debug.Print("Project item " & projItem.Name) Next End Sub
In a VSPackage using the Managed Package Framework (MPF), how do you track the active editor pane in VS? To start with, I create a new VSPackage project (New project -> Other project types -> Extensibility -> Visual Studio Integration Package) and have the wizard create a C# based project with a tool window for me. From the standard button click (to keep things under control easily), I run the following initialization code:
DTE dte = (DTE) GetService(typeof(DTE)); Window outputWindow = (Window) dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); outputWindow.Visible = true; outputPane = ((OutputWindow) outputWindow.Object).OutputWindowPanes.Add("Active window tracking"); outputPane.Activate( ); IVsMonitorSelection monitorSelection = (IVsMonitorSelection) GetService(typeof(SVsShellMonitorSelection)); monitorSelection.AdviseSelectionEvents(this, out myCookie);
VSIP 2005 has been available a while, but I hadn’t found the time to look into it. Now I did and I must say I’m impressed, especially by the new managed classes in the Environment SDK. For example, it’s now possible to create a custom editor for Visual Studio completely in C#, and creating a tool window in managed code is really a matter of a few lines. Great work, I’ll have to have a much closer look at this managed stuff!