VSProject2 Interface
TOC
Collapse the table of content
Expand the table of content

VSProject2 Interface

 

Contains the information specific to a Visual Basic or Visual C# project. The Object object returns it when the project is a Visual Basic or Visual C# project.

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

[GuidAttribute("B1042570-25C6-424A-B58B-56FA83AA828A")]
public interface VSProject2 : VSProject

NameDescription
System_CAPS_pubpropertyBuildManager

Gets the BuildManager object of the VSProject.

System_CAPS_pubpropertyDTE

Gets the top-level extensibility object.

System_CAPS_pubpropertyEvents

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

System_CAPS_pubpropertyEvents2

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

System_CAPS_pubpropertyImports

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

System_CAPS_pubpropertyProject

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

System_CAPS_pubpropertyPublishManager

Gets a PublishManager object to allow click once publishing.

System_CAPS_pubpropertyReferences

Gets the References collection for the project.

System_CAPS_pubpropertyTemplatePath

This property is deprecated in Microsoft Visual Studio 2005. Use GetProjectItemTemplate instead.

System_CAPS_pubpropertyWebReferencesFolder

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).

System_CAPS_pubpropertyWorkOffline

Indicates 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.

NameDescription
System_CAPS_pubmethodAddWebReference(String)

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.

System_CAPS_pubmethodCopyProject(String, String, prjCopyProjectOption, String, String)

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

System_CAPS_pubmethodCreateWebReferencesFolder()

Creates the Web References folder for the project.

System_CAPS_pubmethodExec(prjExecCommand, Int32, Object, Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodGenerateKeyPairFiles(String, String)

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

System_CAPS_pubmethodGetUniqueFilename(Object, String, String)

Generates a unique file name within the project. it is used for naming new project items.

System_CAPS_pubmethodRefresh()

Refreshes the appearance of the project in Solution Explorer and refreshes the references.

Project is a core extensibility object that can contain information about projects of any language. The Object property 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 VSProject2 object.

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

To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

To determine if a Visual Basic or a Visual C# project is a smart device project, use the prjKindSDEVBProject and prjKindSDECSharpProject.

[Visual Basic]

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
 ByVal connectMode As ext_ConnectMode, ByVal addInInst _
 As Object, ByRef custom As Array) Implements _
 IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    VSProject2Example(applicationObject)
End Sub

 Sub VSProject2Example(ByVal dte As DTE2)
    Dim aProject As Project
    Dim aVSProject2 As VSProject2

    aProject = applicationObject.Solution.Projects.Item(1)
    MsgBox(aProject.Kind & aProject.Name)
    If (aProject.Kind = PrjKind.prjKindVBProject) Or_
    (aProject.Kind = PrjKind.prjKindCSharpProject) Then
        aVSProject2 = CType(applicationObject.Solution.Projects.Item(1).Object, _
        VSProject2)
        MsgBox(aVSProject2.Project.FullName)
    Else
        MsgBox("The first project is not a Visual Basic or C# _
        project.")
    End If
End Sub

[C#]

// To use Messabox.Show, a reference to Windows.Forms is required.
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application, ext_ConnectMode
 connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    VSProject2Example((DTE2)applicationObject);
}

public void VSProject2Example(DTE2 dte)
{
    Project aProject = null; 
    VSProject aVSProject2 = null; 
    aProject = applicationObject.Solution.Projects.Item( 1 ); 
    MessageBox.Show( aProject.Kind + aProject.Name); 
    if ( ( aProject.Kind == PrjKind.prjKindVBProject ) |
 ( aProject.Kind == PrjKind.prjKindCSharpProject ) ) 
    { 
        aVSProject2 = ( ( VSProject )
(applicationObject.Solution.Projects.Item( 1 ).Object ) ); 
        MessageBox.Show( aVSProject2.Project.FullName); 
    } 
    else 
    { 
        MessageBox.Show( "The first project is not a Visual Basic or C# project."); 
    } 
}
Return to top
Show:
© 2016 Microsoft