This documentation is archived and is not being maintained.

ServiceHostBase.AddServiceEndpoint Method (String, Binding, String, Uri)

Adds a service endpoint to the hosted service with a specified contract, binding, endpoint address and URI that contains address at which it listens.

Namespace: System.ServiceModel
Assembly: System.ServiceModel (in system.servicemodel.dll)

public ServiceEndpoint AddServiceEndpoint (
	string implementedContract,
	Binding binding,
	string address,
	Uri listenUri
public ServiceEndpoint AddServiceEndpoint (
	String implementedContract, 
	Binding binding, 
	String address, 
	Uri listenUri
public function AddServiceEndpoint (
	implementedContract : String, 
	binding : Binding, 
	address : String, 
	listenUri : Uri
) : ServiceEndpoint
Not applicable.



The contract implemented by the endpoint.


The Binding for the endpoint added.


The String that contains the address for the endpoint added. This address can be an absolute or relative URI.


The Uri that contains the address for the endpoint added.

Return Value

The ServiceEndpoint added to the hosted service.

Exception typeCondition


implementedContract or binding or address or is a null reference (Nothing in Visual Basic).


The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service and so an endpoint cannot be added.

If the address is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0