次の方法で共有


IVsAddWebReferenceDlg3.ShowAddWebReferenceDialog Method

Displays the Add Service Reference dialog box.

Namespace:  Microsoft.VisualStudio.WCFReference.Interop
Assembly:  Microsoft.VisualStudio.WCFReference.Interop (in Microsoft.VisualStudio.WCFReference.Interop.dll)

Syntax

'宣言
Sub ShowAddWebReferenceDialog ( _
    pProject As IVsHierarchy, _
    pDiscoverySession As IDiscoverySession, _
    referenceTypesAllowed As ServiceReferenceType, _
    pszDialogName As String, _
    pExistingReferenceGroup As IVsWCFReferenceGroup, _
    pszReferenceConfigContents As String, _
    <OutAttribute> ByRef ppReferenceResult As IVsAddWebReferenceResult, _
    <OutAttribute> ByRef pfCancelled As Integer _
)
void ShowAddWebReferenceDialog(
    IVsHierarchy pProject,
    IDiscoverySession pDiscoverySession,
    ServiceReferenceType referenceTypesAllowed,
    string pszDialogName,
    IVsWCFReferenceGroup pExistingReferenceGroup,
    string pszReferenceConfigContents,
    out IVsAddWebReferenceResult ppReferenceResult,
    out int pfCancelled
)
void ShowAddWebReferenceDialog(
    [InAttribute] IVsHierarchy^ pProject, 
    [InAttribute] IDiscoverySession^ pDiscoverySession, 
    [InAttribute] ServiceReferenceType referenceTypesAllowed, 
    [InAttribute] String^ pszDialogName, 
    [InAttribute] IVsWCFReferenceGroup^ pExistingReferenceGroup, 
    [InAttribute] String^ pszReferenceConfigContents, 
    [OutAttribute] IVsAddWebReferenceResult^% ppReferenceResult, 
    [OutAttribute] int% pfCancelled
)
abstract ShowAddWebReferenceDialog : 
        pProject:IVsHierarchy * 
        pDiscoverySession:IDiscoverySession * 
        referenceTypesAllowed:ServiceReferenceType * 
        pszDialogName:string * 
        pExistingReferenceGroup:IVsWCFReferenceGroup * 
        pszReferenceConfigContents:string * 
        ppReferenceResult:IVsAddWebReferenceResult byref * 
        pfCancelled:int byref -> unit 
function ShowAddWebReferenceDialog(
    pProject : IVsHierarchy, 
    pDiscoverySession : IDiscoverySession, 
    referenceTypesAllowed : ServiceReferenceType, 
    pszDialogName : String, 
    pExistingReferenceGroup : IVsWCFReferenceGroup, 
    pszReferenceConfigContents : String, 
    ppReferenceResult : IVsAddWebReferenceResult, 
    pfCancelled : int
)

Parameters

  • pszDialogName
    Type: String
    A String that contains the title for the dialog box. Can be Null.
  • pszReferenceConfigContents
    Type: String
    A String that contains the configuration contents.
  • pfCancelled
    Type: Int32%
    An Integer specifying whether the dialog box was canceled.

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.

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;
    }
}

.NET Framework Security

See Also

Reference

IVsAddWebReferenceDlg3 Interface

Microsoft.VisualStudio.WCFReference.Interop Namespace