VSProject Interface


Contains the information specific to a Visual Basic or C# project. It is returned by the Object object when the project is a Visual Basic or Visual C# project.

public interface class VSProject
public interface class VSProject
__interface VSProject
public interface VSProject
public interface VSProject
type VSProject = interface
type VSProject = interface
Public Interface VSProject


[Visual Basic]

' Macro Editor  
' This example retrieves the VSProject object if the first project  
' the solution is a Visual Basic or C# project. This routine assumes  
' that the solution contains at least one project.  
Imports VSLangProj  
Sub VSProjectExample()  
   Dim aProject As Project  
   Dim aVSProject As VSProject  

   aProject = DTE.Solution.Projects.Item(1)  
   If (aProject.Kind = PrjKind.prjKindVBProject) _  
   Or (aProject.Kind = PrjKind.prjKindCSharpProject) Then  
      aVSProject = CType(DTE.Solution.Projects.Item(1).Object, VSProject)  
      MsgBox("The first project is not a Visual Basic or C# project.")  
   End If  
End Sub  


Project is a core extensibility object that can contain information about projects of any language. The Object of the Project object returns an object whose type depends on the project language used. In the case of Visual Basic and Visual C#, that object is a VSProject object.

The Object returns an Object data type. The data object returned by the Object may then be explicitly converted to VSProject. The example below demonstrates this conversion using the CType function. The PrjKind is used to test for the project's type before the conversion.



Gets the BuildManager object of the VSProject. Read-only.


Gets the top-level extensibility object.


Gets a VSProjectEvents object that allows you to respond to events of the Imports, References, and BuildManager objects.


Gets the Imports object associated with the project. For C# projects, the Imports property is set to Nothing (a null reference). Read-only.


Gets the generic Project object associated with the Visual Basic or Visual C# project. Read-only.


Gets the References collection for the project. Read-only.


Gets the full path of the directory that contains the project-item templates for Visual Basic or C#. Read-only.


Gets the ProjectItem object representing the Web References folder of the project. If the folder does not exist, this property returns Nothing (a null reference). Read-only.


Gets or sets whether a Web project is working online or offline. When it is working offline, development continues on an offline store of project files, so that the project files on the server are not changed.



Adds a reference to a Web Service to the project. A new Web Service reference subfolder is added to the Web References folder of the project. This new folder contains several other project items related to the Web Service. The method returns the ProjectItem object associated with the new Web Service folder.

CopyProject(String, String, prjCopyProjectOption, String, String)

Copies some or all of a Web project to a new location.


Creates the Web References folder for the project.

Exec(prjExecCommand, Int32, Object, Object)

Microsoft Internal Use Only.

GenerateKeyPairFiles(String, String)

Generates a public/private key file used to form a strong name for the assembly.

GetUniqueFilename(Object, String, String)

Generates a unique file name within the project. Used for naming new project items.


Refreshes the appearance of the project in Solution Explorer, refreshes the references, and gets the latest compiled versions of the files.

Applies to