How to get project items from VS add-in


Author
Message
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
I am trying to create an VS add in for my reporting engine. I need to be able to loop through each project and then loop through the project and find reports by type. (Like you do with the Bo Mapper) .. i am trying something like below just cannot figure out how to load or just get at the assembly. thanks for  any help

Dim LoProject As Project

Dim loAssembly As Reflection.Assembly

Try

'Check to see if Solution is open, I forget everytime debugging this

If Not _appobject.Solution.IsOpen Then

MessageBox.Show("Please load solution")

Else

For Each LoProject In _appobject.Solution.Projects

'show what projects we have

MessageBox.Show("Project Name: " & LoProject.FullName)

'-- Here i need to be able to load the assembly and then do through the types

' loAssembly = Reflection.Assembly.Load

For Each loType As Type In loAssembly.GetTypes()

If loType.IsSubclassOf(GetType(DevExpress.XtraReports.UI.XtraReport)) Then

Me.ListView1.Items.Add(loType.FullName)

End If

Next

Next

End If

Catch objException As System.Exception

MessageBox.Show(objException.ToString)

End Try


 

Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You are going to have to use the EnvDTE name space, you will then wan to get a DTE object and once you have that, you will be able to get the ActiveSolution, and enumerate the Projects with the solution:

You will want to create a class and implement the IDTExtensibility2 implemention on your class.  This will require that a method called OnConnection be created.  This method has a parameter called Application which can be typed as a DTE or DTE2 object, and this will be your entry point:

Imports EnvDTE
Imports EnvDTE80

Public Class MyAddIn
 Implements IDTExtensibility2

 Private _DTE As DTE2

 Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, ByRef custom As Array) Implements IDTExtensibility2.OnConnection
  _DTE = CTYpe(application, DTE2)

 End Sub

End Class

You can also create a wizard class that implements the IWizard interface which will give you a similar starting point and you can tie into template that shows up under (New Item).  This will allow you to provide additional functionality when creating a new item.  This class has a RunStarted method on that implemention and the automationObject is the DTE object in this case.

Once you have the DTE object, you can then get the active solution and project items:

For Each proj As EnvDTE.Project In _DTE.Solution.Projects
    '-- You can access the project and pretty much everything associated with that project
    For each item as ProjectItem in proj.ProjectItems
    Next
Next

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search