IVsAddWebReferenceDlg3.ShowAddWebReferenceDialog Method

Definition

Displays the Add Service Reference dialog box.

public:
 void ShowAddWebReferenceDialog(Microsoft::VisualStudio::Shell::Interop::IVsHierarchy ^ pProject, Microsoft::VisualStudio::Shell::Interop::IDiscoverySession ^ pDiscoverySession, Microsoft::VisualStudio::WCFReference::Interop::ServiceReferenceType referenceTypesAllowed, System::String ^ pszDialogName, Microsoft::VisualStudio::WCFReference::Interop::IVsWCFReferenceGroup ^ pExistingReferenceGroup, System::String ^ pszReferenceConfigContents, [Runtime::InteropServices::Out] Microsoft::VisualStudio::WCFReference::Interop::IVsAddWebReferenceResult ^ % ppReferenceResult, [Runtime::InteropServices::Out] int % pfCancelled);
void ShowAddWebReferenceDialog(Microsoft::VisualStudio::Shell::Interop::IVsHierarchy const & pProject, Microsoft::VisualStudio::Shell::Interop::IDiscoverySession const & pDiscoverySession, Microsoft::VisualStudio::WCFReference::Interop::ServiceReferenceType referenceTypesAllowed, std::wstring const & pszDialogName, Microsoft::VisualStudio::WCFReference::Interop::IVsWCFReferenceGroup const & pExistingReferenceGroup, std::wstring const & pszReferenceConfigContents, [Runtime::InteropServices::Out] Microsoft::VisualStudio::WCFReference::Interop::IVsAddWebReferenceResult const & & ppReferenceResult, [Runtime::InteropServices::Out] int & pfCancelled);
public void ShowAddWebReferenceDialog (Microsoft.VisualStudio.Shell.Interop.IVsHierarchy pProject, Microsoft.VisualStudio.Shell.Interop.IDiscoverySession pDiscoverySession, Microsoft.VisualStudio.WCFReference.Interop.ServiceReferenceType referenceTypesAllowed, string pszDialogName, Microsoft.VisualStudio.WCFReference.Interop.IVsWCFReferenceGroup pExistingReferenceGroup, string pszReferenceConfigContents, out Microsoft.VisualStudio.WCFReference.Interop.IVsAddWebReferenceResult ppReferenceResult, out int pfCancelled);
abstract member ShowAddWebReferenceDialog : Microsoft.VisualStudio.Shell.Interop.IVsHierarchy * Microsoft.VisualStudio.Shell.Interop.IDiscoverySession * Microsoft.VisualStudio.WCFReference.Interop.ServiceReferenceType * string * Microsoft.VisualStudio.WCFReference.Interop.IVsWCFReferenceGroup * string * IVsAddWebReferenceResult * int -> unit
Public Sub ShowAddWebReferenceDialog (pProject As IVsHierarchy, pDiscoverySession As IDiscoverySession, referenceTypesAllowed As ServiceReferenceType, pszDialogName As String, pExistingReferenceGroup As IVsWCFReferenceGroup, pszReferenceConfigContents As String, ByRef ppReferenceResult As IVsAddWebReferenceResult, ByRef pfCancelled As Integer)

Parameters

pProject
IVsHierarchy

The IVsHierarchy for the project where the reference will be added.

pDiscoverySession
IDiscoverySession

The IVsDiscoveryService session to use for the metadata download.

referenceTypesAllowed
ServiceReferenceType

The ServiceReferenceType for the reference; either Windows Communication Foundation (WCF) or or Web services (ASMX) that use ASP.NET.

pszDialogName
String

A String that contains the title for the dialog box. Can be Null.

pExistingReferenceGroup
IVsWCFReferenceGroup

An existing IVsWCFReferenceGroup. Can be Null.

pszReferenceConfigContents
String

A String that contains the configuration contents.

ppReferenceResult
IVsAddWebReferenceResult

A IVsAddWebReferenceResult object that contains the results. Can be Null if the dialog box was canceled.

pfCancelled
Int32

An Integer specifying whether the dialog box was canceled.

Examples

The following example demonstrates how to display the Add Service Reference dialog box.

/// Add a service reference to the given project.   
private static IVsWCFReferenceGroup TryAddServiceReference  
 (IVsHierarchy hierarchy, IServiceProvider serviceProvider,  
 IDiscoverySession discoverySession)  
{  
    Debug.Assert(serviceProvider != null, "Why are we passing in a NULL  
 service provider to a private method?");  

    IVsAddWebReferenceDlg3 awrdlg =   
 serviceProvider.GetService(typeof(SVsAddWebReferenceDlg3))  
 as IVsAddWebReferenceDlg3;  
    IVsAddWebReferenceResult addWebReferenceResult = null;  
    int cancelled = 1;  

    if (awrdlg != null && hierarchy != null)  
    {  
        awrdlg.ShowAddWebReferenceDialog(             hierarchy,             discoverySession,             ServiceReferenceType.SRT_WCFReference,             null,             null,             null,             out addWebReferenceResult,             out cancelled);  
    }  

    if (addWebReferenceResult != null && cancelled == 0)  
    {  
        return addWebReferenceResult.Save() as IVsWCFReferenceGroup;  
    }  
    else  
    {  
         return null;  
    }  
}  

Remarks

The Add Service Reference dialog box allows a user to specify a metadata download address, downloads the service metadata, and displays information about the service.

If the service metadata download is successful and the user closes the dialog box by clicking OK, the consumer of the service (for example the project system) should call the Save method of the returned IVsAddWebReferenceResult object. This causes a new WCF reference to be added to the project and the service proxy to be generated. The IVsAddWebReferenceResult object can also be cached and used to create a service reference later.

ShowAddWebReferenceDialog fails immediately if the project does not support storage service, or VSPROPID_ServiceReferenceSupported property of the project is not true.

Applies to