Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Basic (Classic) FAQ


Get Project information from EnvDTE at Design time by SBendBuckeye
Posted: 22 Jan 07

Hello all,

I was working on some code and needed to access Project information at design time. It was a real struggle to find any documentation on how to do that. Below is a method I wrote which help me get started.

A. I put this code inside a Designer class because I needed to use GetService and Component.Site provides a GetService method

B. You will need to set a reference to envdte for the code to work.


Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
        Dim visualStudioIDE As EnvDTE.DTE = _
            CType(component.Site.GetService(GetType(EnvDTE.DTE)), EnvDTE.DTE)
        If visualStudioIDE Is Nothing Then Throw New InvalidOperationException("DTE not found.")
        Dim o, projects, mainWindow As Object
        Dim ad As EnvDTE.Document
        Dim aw As EnvDTE.Window
        Dim docs As EnvDTE.Documents
        Dim mode As EnvDTE.vsIDEMode
        Dim solution As EnvDTE.Solution
        Dim windows As EnvDTE.Windows
        With visualStudioIDE
            ad = .ActiveDocument
            projects = .ActiveSolutionProjects
            aw = .ActiveWindow
            docs = .Documents
            o = .GetObject("VBProjects")
            mode = .Mode
            mainWindow = .MainWindow
            solution = .Solution
            windows = .Windows
        End With

        Dim text As String
        For Each [property] As EnvDTE.Property In aw.Project.Properties
            text &= [property].Name & " " & [property].Value.ToString & vbNewLine
        MsgBox(text, MsgBoxStyle.Information)

        text = String.Empty
        For Each item As EnvDTE.ProjectItem In aw.Project.ProjectItems
            text &= item.Name & " " & item.FileNames(0) & vbNewLine
        MsgBox(text, MsgBoxStyle.Information)

    Catch ex As Exception
    End Try
End Sub 'Initialize

Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close