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 | |
---|---|---|
BuildManager | Gets the BuildManager object of the VSProject. Read-only. | |
DTE | Gets the top-level extensibility object. | |
Events | Gets a VSProjectEvents object that allows you to respond to events of the Imports, References, and BuildManager objects. | |
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. | |
Project | Gets the generic Project object associated with the Visual Basic or Visual C# project. Read-only. | |
References | Gets the References collection for the project. Read-only. | |
TemplatePath | Gets the full path of the directory that contains the project-item templates for Visual Basic or C#. Read-only. | |
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. | |
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 | |
---|---|---|
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. | |
CopyProject | Copies some or all of a Web project to a new location. | |
CreateWebReferencesFolder | Creates the Web References folder for the project. | |
Exec | Infrastructure. Microsoft Internal Use Only. | |
GenerateKeyPairFiles | Generates a public/private key file used to form a strong name for the assembly. | |
GetUniqueFilename | Generates a unique file name within the project. Used for naming new project items. | |
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