Freigeben über


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.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

Syntax

'Declaration
<GuidAttribute("2CFB826F-F6BF-480D-A546-95A0381CC411")> _
Public Interface VSProject
[GuidAttribute("2CFB826F-F6BF-480D-A546-95A0381CC411")]
public interface VSProject
[GuidAttribute(L"2CFB826F-F6BF-480D-A546-95A0381CC411")]
public interface class VSProject
[<GuidAttribute("2CFB826F-F6BF-480D-A546-95A0381CC411")>]
type VSProject =  interface end
public interface VSProject

The VSProject type exposes the following members.

Properties

  Name Description
Public property BuildManager Gets the BuildManager object of the VSProject. Read-only.
Public property DTE Gets the top-level extensibility object.
Public property Events Gets a VSProjectEvents object that allows you to respond to events of the Imports, References, and BuildManager objects.
Public property Imports Gets the Imports object associated with the project. For C# projects, the Imports property is set to Nothing (a nulla null reference (Nothing in Visual Basic) reference). Read-only.
Public property Project Gets the generic Project object associated with the Visual Basic or Visual C# project. Read-only.
Public property References Gets the References collection for the project. Read-only.
Public property TemplatePath Gets the full path of the directory that contains the project-item templates for Visual Basic or C#. Read-only.
Public property WebReferencesFolder Gets the ProjectItem object representing the Web References folder of the project. If the folder does not exist, this property returns Nothing (a nulla null reference (Nothing in Visual Basic) reference). Read-only.
Public property WorkOffline 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.

Top

Methods

  Name Description
Public method AddWebReference 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.
Public method CopyProject Copies some or all of a Web project to a new location.
Public method CreateWebReferencesFolder Creates the Web References folder for the project.
Public method Exec Infrastructure. Microsoft Internal Use Only.
Public method GenerateKeyPairFiles Generates a public/private key file used to form a strong name for the assembly.
Public method GetUniqueFilename Generates a unique file name within the project. Used for naming new project items.
Public method Refresh Refreshes the appearance of the project in Solution Explorer, refreshes the references, and gets the latest compiled versions of the files.

Top

Remarks

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.

Examples

[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(aVSProject.Project.FullName)
   Else
      MsgBox("The first project is not a Visual Basic or C# project.")
   End If
End Sub

See Also

Reference

VSLangProj Namespace