Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you declare a DTE object?

Status
Not open for further replies.

KPharm

Programmer
Feb 1, 2001
38
US
The example given by MS in the MDSN doesn't tell you how to declare the DTE object or import it's namespace, etc, so the code segment below doesn't work. I'm just trying to add a reference path at runtime and it recommends using the DTE. Has anyone been able to instantiate such an object?

Thx

ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vxlrfvslangprojprojectpropertiesreferencepath.htm

Sub AddReferencePath(ByVal pathToAdd As String)
Dim currentPath As String
Dim newPath As String
currentPath = _
DTE.Solution.Projects.Item(1).Properties.Item("ReferencePath").Value
newPath = currentPath & ";" & pathToAdd
DTE.Solution.Projects.Item(1).Properties.Item("ReferencePath").Value _
= newPath
End Sub
 
After awhile, I answered my own question. The following will return all the info you need:

After adding a .net reference to "envdte":

Imports EnvDTE

Dim o As DTE
Dim i As Integer

o = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE"), DTE)

ListBox1.Items.Clear()

For i = 1 To o.Solution.Item(1).Properties.Count

ListBox1.Items.Insert(0, CStr(i) & ": " & o.Solution.Item(1).Properties.Item(i).Name & ": " & CStr(o.Solution.Item(1).Properties.Item(i).Value))
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top