Project.Globals Property

Definition

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

C++/CX
public:
 property EnvDTE::Globals ^ Globals { EnvDTE::Globals ^ get(); };

Property Value

A Globals object.

Attributes

Examples

VB
Public Sub CodeExample(ByVal dte As DTE2)   
    Try  
        ' Open a project before running this sample.  
        Dim prj As Project = dte.Solution.Projects.Item(1)  
        Dim prjs As Projects  
        Dim msg2 As String = "Global Variables:"  
        Dim msg As String  
        msg = "FileName: " + prj.FileName  
        msg += vbCrLf + "FullName: " + prj.FullName  
        msg += vbCrLf + "Project-level access to " + prj.CodeModel.CodeElements.Count.ToString() + " CodeElements through the CodeModel"  
        prjs = prj.Collection  
        msg += vbCrLf + "There are " + prjs.Count.ToString() + " projects in the same collection."  
        msg += vbCrLf + "Application containing this project: " + prj.DTE.Name  
        If prj.Saved Then  
            msg += vbCrLf + "This project has not been modified since the last save."  
        Else  
            msg += vbCrLf + "This project has been modified since the last save."         
        End If  
        msg +=  vbCrLf + "Properties:"  
        Dim prop As [Property]  
        For Each prop In  prj.Properties  
            msg += vbCrLf + "  " + prop.Name  
        Next prop  
        Dim s As String  
        For Each s In  CType(prj.Globals.VariableNames, Array)  
            msg2 += vbCrLf + "  " + s  
        Next s  

        MessageBox.Show(msg, "Project Name: " + prj.Name)  
        MessageBox.Show(msg2)  
    Catch ex As Exception  
        MessageBox.Show(ex.Message)  
    End Try  
End Sub  

Remarks

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

Solution globals are associated with automation clients.

Napomena

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."

Applies to

Proizvod Verzije
Visual Studio SDK 2015, 2017, 2019, 2022