Article ID: 555467 - View products that this article applies to.
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.
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:
Dim objProject As EnvDTE.Project
Dim objVSProject As VSLangProj.VSProject
Dim objReference As VSLangProj.Reference
Dim sMsg As String
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
sMsg &= " (Source Project)"
sMsg &= CrLf
Catch objException As System.Exception
Article ID: 555467 - Last Review: October 6, 2005 - Revision: 1.0
COMMUNITY SOLUTIONS CONTENT DISCLAIMER
MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.