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: Get an EnvDTE.Project object from its project unique name

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

Introduction

Projects in Visual Studio have three names:

  • The name of the project in the Solution Explorer (EnvDTE.Project.Name property).
  • The full name of the project file (EnvDTE.Project.FullName property),

Since a solution could contain two projects with the same name saved in different folders, the name of a project is not unique, and can't be used to locate a project in a solution. To solve this, Visual Studio provides a third name property:

  • The unique name of a project (EnvDTE.Project.UniqueName property). If needed, the unique name of a project contains the folder where it is located.

The unique name of a project identifies it unambiguously. This article explains how to get the EnvDTE.Project object given its project unique name.

More Information

Given a project unique name, for example the Project parameter of the OnBuildProjConfigBegin event of the EnvDTE.BuildEvents class:

Public Event OnBuildProjConfigBegin(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String)

sometimes you need to get the EnvDTE.Project object that is being built. You can't use the EnvDTE.Solution.Projects collection to locate the EnvDTE.Project, since that collection only lists first-level projects, and a project can be nested inside a folder or another project. Although you could locate the EnvDTE.Project object iterating recursively that collection (as described in the article HOWTO: Navigate the files of a solution from a Visual Studio .NET macro or add-in), that approach would be overkill. The extensibility model offers the following method to retrieve the EnvDTE.Project of a project unique name:

EnvDTE.Solution.Item(ByVal projectUniqueName As String) As EnvDTE.Project.

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