Project.Globals Property

Gets the Globals object containing add-in values that may be saved in the solution (.sln) file, the project file, or in the user's profile data.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Globals Globals { get; }

Property Value

Type: EnvDTE.Globals
A Globals object.

The add-ins are available when the solution, project file, and so on are loaded.

Solution globals are not necessarily associated with add-ins. They can also be associated with macros or other automation clients.


VariableValue name strings cannot contain space, colon (:), or period(.) characters. If a name has any of these characters, you get the error, "Value does not fall within expected range."

public void CodeExample(DTE2 dte)
    {   // Open a project before running this sample.
        Project prj = dte.Solution.Projects.Item(1);
        Projects prjs;
        string msg, msg2 = "Global Variables:";
        msg = "FileName: " + prj.FileName;
        msg += "\nFullName: " + prj.FullName;
        msg += "\nProject-level access to " + prj.CodeModel.CodeElements.Count.ToString() +
            " CodeElements through the CodeModel";
        prjs = prj.Collection;
        msg += "\nThere are " + prjs.Count.ToString() + " projects in the same collection.";
        msg += "\nApplication containing this project: " + prj.DTE.Name;
        if (prj.Saved)
            msg += "\nThis project hasn't been modified since the last save.";
            msg += "\nThis project has been modified since the last save.";
        msg += "\nProperties: ";
        foreach (Property prop in prj.Properties)
            msg += "\n  " + prop.Name;
        foreach (String s in (Array)prj.Globals.VariableNames)
            msg2 += "\n  " + s;

        MessageBox.Show(msg, "Project Name: " + prj.Name);
    catch(Exception ex)

Community Additions