This documentation is archived and is not being maintained.

_Solution.Globals Property

Gets the Globals that contains 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 */
Globals get_Globals ()

function get Globals () : Globals

Property Value

A Globals object.

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

Solution globals aren't necessarily add-in created; they can also be created by macros or any other automation client.

public void GlobalsExample(DTE2 dte)

    // NOTE: This example requires a reference to the
    //       System.IO namespace.

    // Before running this example, open a solution.

    Solution soln = dte.Solution;
    string solnName = Path.GetFileNameWithoutExtension(soln.FullName);

        "Adding global variable TempGlobal = \"TempValue\"");

    soln.Globals["TempGlobal"] = "TempValue";

    object[] names = (object[])soln.Globals.VariableNames;
    string globals = "";

    foreach (string name in names)
        globals += "    " + name + " = \"" + 
            soln.Globals[name].ToString() + "\"\n";

    MessageBox.Show("Solution " + solnName + 
        " has the following global variables:\n\n" + globals);