Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Getting information specific to VB.NET and C# projects from an add-in or macro

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: October 2005   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005
Introduction

This article describes how to get information not available in the general extensibility model of Visual Studio .NET (EnvDTE namespace) because it is specific to VB.NET and C# projects.

More Information

Visual Studio .NET supports many kind of projects (VB.NET, C#, C++, setup, database, etc.) and therefore the EnvDTE namespace provided by the EnvDTE.dll assembly only exposes the functionality common to all of them. For example, the information about references of VB.NET and C# projects, which do not apply to other kind of projects, is not exposed by that assembly. The extensibility model specific to VB.NET and C# projects resides in a different assembly named VSLangProj.dll. That assembly can be used in both Visual Studio .NET 2002 and 2003 (the later provides also a VSLangProj2.dll assembly with additional classes). You can get objects of the VSLangProj assembly from the objects of the EnvDTE assembly through its "Object" property. For example, you can cast the property EnvDTE.Project.Object to an VSLangProj.VSProject for VB.NET and C# projects. The following macro shows how to get the information about the references of a VB.NET or C# project:

Sub DisplayProjectReferences()
 
   Dim objProject As EnvDTE.Project
   Dim objVSProject As VSLangProj.VSProject
   Dim objReference As VSLangProj.Reference
   Dim sMsg As String
 
   Try
 
      For Each objProject In DTE.Solution.Projects
 
          If TypeOf objProject.Object Is VSLangProj.VSProject Then

              objVSProject = DirectCast(objProject.Object, VSLangProj.VSProject)
 
              sMsg = "References of project " & objProject.Name & ":" & CrLf & CrLf
 
              For Each objReference In objVSProject.References

                  sMsg &= objReference.Name

                  If objReference.SourceProject Is Nothing Then
                      sMsg &= " " & objReference.Version
                  Else
                      sMsg &= " (Source Project)"
                  End If

                  sMsg &= CrLf

              Next
 
              MessageBox.Show(sMsg)

          End If
 
      Next
 
   Catch objException As System.Exception
      MessageBox.Show(objException.ToString)
   End Try
 
End Sub

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this

MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top