IVsAddWebReferenceDlg3::ShowAddWebReferenceDialog Method (IVsHierarchy^, IDiscoverySession^, ServiceReferenceType, String^, IVsWCFReferenceGroup^, String^, IVsAddWebReferenceResult^, Int32)
Displays the Add Service Reference dialog box.
Assembly: Microsoft.VisualStudio.WCFReference.Interop (in Microsoft.VisualStudio.WCFReference.Interop.dll)
void ShowAddWebReferenceDialog( IVsHierarchy^ pProject, IDiscoverySession^ pDiscoverySession, ServiceReferenceType referenceTypesAllowed, String^ pszDialogName, IVsWCFReferenceGroup^ pExistingReferenceGroup, String^ pszReferenceConfigContents, [OutAttribute] IVsAddWebReferenceResult^% ppReferenceResult, [OutAttribute] int% pfCancelled )
Parameters
- pProject
-
Type:
Microsoft.VisualStudio.Shell.Interop::IVsHierarchy^
The IVsHierarchy for the project where the reference will be added.
- pDiscoverySession
-
Type:
Microsoft.VisualStudio.Shell.Interop::IDiscoverySession^
The IVsDiscoveryService session to use for the metadata download.
- referenceTypesAllowed
-
Type:
Microsoft.VisualStudio.WCFReference.Interop::ServiceReferenceType
The ServiceReferenceType for the reference; either Windows Communication Foundation (WCF) or or Web services (ASMX) that use ASP.NET.
- pszDialogName
-
Type:
System::String^
A String that contains the title for the dialog box. Can be Null.
- pExistingReferenceGroup
-
Type:
Microsoft.VisualStudio.WCFReference.Interop::IVsWCFReferenceGroup^
An existing IVsWCFReferenceGroup. Can be Null.
- pszReferenceConfigContents
-
Type:
System::String^
A String that contains the configuration contents.
- ppReferenceResult
-
Type:
Microsoft.VisualStudio.WCFReference.Interop::IVsAddWebReferenceResult^
A IVsAddWebReferenceResult object that contains the results. Can be Null if the dialog box was canceled.
- pfCancelled
-
Type:
System::Int32
An Integer specifying whether the dialog box was canceled.
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.
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;
}
}