VSProject2.CreateWebReferencesFolder Method

Definition

Creates the Web References folder for the project.

public:
 EnvDTE::ProjectItem ^ CreateWebReferencesFolder();
public:
 EnvDTE::ProjectItem ^ CreateWebReferencesFolder();
EnvDTE::ProjectItem CreateWebReferencesFolder();
[System.Runtime.InteropServices.DispId(5)]
public EnvDTE.ProjectItem CreateWebReferencesFolder ();
abstract member CreateWebReferencesFolder : unit -> EnvDTE.ProjectItem
Public Function CreateWebReferencesFolder () As ProjectItem

Returns

Implements

Attributes

Examples

This example creates a Web References folder. The first project in the solution must be a Visual Basic or Visual C# project for the example to work properly. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

[Visual Basic]

' Add-in code.  
Imports VSLangProj  
Imports VSLangProj80  
' This example creates a Web References folder, if it does not   
' already exist, and displays some properties of the folder.  
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)  
    WebReferencesFolderExample(applicationObject)  
End Sub  
  
Sub WebReferencesFolderExample(ByVal dte As DTE2)  
    ' This example assumes that the first project in the solution is   
    ' a Visual Basic or C# project.  
    Dim aVSProject As VSProject2 = _  
    CType(applicationObject.Solution.Projects.Item(1).Object, _  
    VSProject2)  
    ' Add a new folder if it does not already exist.  
    If (aVSProject.WebReferencesFolder Is Nothing) Then  
        Dim webFolder As ProjectItem  
        webFolder = aVSProject.CreateWebReferencesFolder()  
    End If  
    ' Display the name of the Web References folder.  
    Dim theFolder As ProjectItem = aVSProject.WebReferencesFolder  
    MsgBox("The name of the WebReferences folder is " _  
    & theFolder.Name & ".")  
  
    If (theFolder.Kind = _  
        EnvDTE.Constants.vsProjectItemKindPhysicalFolder) Then  
        MsgBox(theFolder.Name & " is a physical folder.")  
    End If  
    MsgBox("There are " & theFolder.ProjectItems.Count.ToString() & _  
    " Web references.")  
End Sub  

[C#]

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;  
    WebReferencesFolderExample((DTE2)applicationObject);  
}  
  
public void WebReferencesFolderExample(DTE2 dte)  
{  
    // This example assumes that the first project in the solution is   
    // a Visual Basic or C# project.  
    VSProject2 aVSProject =   
((VSProject2)( applicationObject.Solution.Projects.Item(1).Object));  
  
    // Add a new folder if it does not already exist.  
    if ((aVSProject.WebReferencesFolder == null))  
    {  
        ProjectItem webFolder = null;  
        webFolder = aVSProject.CreateWebReferencesFolder();  
    }  
    // Display the name of the Web References folder.  
    ProjectItem theFolder = aVSProject.WebReferencesFolder;  
    MessageBox.Show("The name of the WebReferences folder is "  
 + theFolder.Name + ".");  
  
    if ((theFolder.Kind ==   
EnvDTE.Constants.vsProjectItemKindPhysicalFolder))  
    {  
        MessageBox.Show(theFolder.Name + " is a physical folder.");  
    }  
    MessageBox.Show("There are " +   
theFolder.ProjectItems.Count.ToString() + " Web references.");  
}  

Remarks

If the Web References folder already exists, then this property returns the ProjectItem for the existing folder.

Applies to